Reputation:
In my blogger template I have the following code:
<b:if cond='data:blog.pageType == "index"'>
<!-- A lot of lines of code -->
</b:if>
<b:if cond='data:blog.pageType == "archive"'>
<!-- The same lines of code -->
</b:if>
It is possible to merge both 'if's in a unique expresión?. Something like using a simple logical OR?. I've tried the following with no result:
<b:if cond='data:blog.pageType == "index" ||
data:blog.pageType == "index"'>
<b:if cond='data:blog.pageType == "index" ||
data:blog.pageType == "index"'>
<b:if cond='data:blog.pageType == "index" OR
data:blog.pageType == "index"'>
<b:if cond='data:blog.pageType == "index" || "index"'>
<b:if cond='data:blog.pageType == "index" || "index"'>
Note: | is the HTML expression for '|'.
I google it with no result, and I also reviewed blogger b:if statement, but I found no answer to this simple question.
----- edited -----
The desired result is having a code like:
<b:if cond='data:blog.pageType == "index"' ||
cond='data:blog.pageType == "archive"'>
<!-- A lot of lines of code -->
</b:if>
In this way, I don't repeat the block 'lot of lines of code', resulting a more maintainable code, and simplier.
Anyway, knowing how to do a simple OR is a good thing to furure cases.
Upvotes: 1
Views: 2067
Reputation:
The only way I found to accomplish this is transforming the OR to nested, negated ANDs.
In this case, 'data:blog.pageType' has only 4 valid values: item, static, index and archive. So, the following code do the trick:
<b:if cond='data:blog.pageType != "item"'>
<b:if cond='data:blog.pageType != "static"'>
<!-- This block is run only when the pageType is archive or index -->
<!-- A lot of lines of code -->
</b:if>
</b:if>
Edit: This works fine, but maybe you'll want to try the accepted answer given by Marcos.
Upvotes: 1
Reputation: 3323
To simulate an OR operator in a blogger template, just use the IN operator.
In your case:
<b:if cond='data:blog.pageType in {"index","archive"}'>
<!-- This block is run only when the pageType is index or archive-->
</b:if>
Upvotes: 4