blogger b:if statement

笑着哭i 提交于 2019-12-21 22:19:53

问题


i would like to ask if there is an elseif statement in blogger? All i've seen is only if and else but no elseif.

If there isn't any elseif statement, how can i give multiple condition to an if statement?

For instance in this case, i have 3 author A B and C. Recently D and E have joined us, i have a code such that if the author is A B or C, it will post their respective images

<b:if cond='data:post.author == &quot;Author-A&quot;'>

<img class='ava' height='100'
src='img-URL-1'
width='100'/>

</b:if>
<b:if cond='data:post.author == &quot;Author-B&quot;'>

<img class='ava' height='100'
src='img-URL-2'
width='100'/>

</b:if>

and so on. But if the author is not A B or C, the CSS would screw up my blog post, so i thought of using elseif for this and if elseif is not available in this case, i thought of adding this after the above code

<b:if cond='data:post.author != &quot;Author-A&quot && &quot;Author-B&quot && &quot;Author-C&quot;'>

<img class='ava' height='100'
src='else-IMG-URL'
width='100'/>

</b:if>

But i've tried that and it doesn't seem to work it says && is invalid. Any idea what i should put in to use as OR ?


回答1:


Translated in pseudocode you logically rather want to do the following:

if (author != A && author != B && author != C)

and thus not what you tried:

if (author != A && B && C)



回答2:


<b:if cond='condition1'>
    Do something for 1
<b:else/>
    <b:if cond='condition2'>
        Do something for 2
    <b:else/>
        <b:if cond='condition3'>
            Do something for 3
        <b:else/>
            Do something for others
        </b:if>
    </b:if>
</b:if>



回答3:


if you want to do a logical end-ing then use this format:

<b:if cond='condition 1'>
<b:if cond='condition 2'>
contents go here
</b:if>  
</b:if> 



回答4:


Perhaps you need to specify && as &amp;&amp;?

That should resolve the error message you're getting. You will likely still have to fix the logic problem that BalusC pointed out.



来源:https://stackoverflow.com/questions/2032211/blogger-bif-statement

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!