Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional statement in blogger template is not working

Tags:

xml

blogger

In my blogger template add a conditional statement. But it is not working. It is always display 'Not equal'

Home url: http://abc.blogspot.in

Page url: http://abc.blogspot.in/p/my-page-url.html

For testing purpose i had pasted the below code after '<body>' tag.

<b:if cond='data:blog.url == data:blog.homepageUrl + &quot;p/my-page-url.html&quot;'> 
<h1>Equal</h1>
<b:else/>
<h1>Not equal</h1>
</b:if>

I had printed the value of <data:blog.url/> and <data:blog.homepageUrl/>p/my-page-url.html and it is same.

updates:

<b:if cond='data:blog.url == &quot;http://abc.blogspot.in/p/my-page-url.html&quot;'> 
    <h1>Equal</h1>
    <b:else/>
    <h1>Not equal</h1>
    </b:if>

//Not equal

<b:if cond='data:blog.url == &quot;http://abc.blogspot.com/p/my-page-url.html&quot;'> 
    <h1>Equal</h1>
    <b:else/>
    <h1>Not equal</h1>
    </b:if>

//Equal

Thank You

like image 300
Pamba Avatar asked Nov 20 '25 05:11

Pamba


2 Answers

Replace the above code with this

<b:if cond='data:blog.pageId == "PAGE_ID"'>
    <h1>Equal</h1>
    <b:else/>
    <h1>Not equal</h1>
    </b:if>

To find the PAGE_ID go to Pages, now click edit to open the page in Blogger post editor. In the address bar you may find something like this "pageID=6284317258827606063" now copy the page id and replace with the PAGE_ID above.

like image 96
Sifatur Rahman Avatar answered Nov 23 '25 23:11

Sifatur Rahman


Replace the '+' with 'path' without '.

like image 23
Patternpy Avatar answered Nov 23 '25 22:11

Patternpy