Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blogger Search Label Conditional Statements

I'm trying to add CSS in blogger based on URL. The URL is a search of multiple labels using: http://www.website.com/search/?q=label:Graphics|label:Identity|label:Brand . The search for multiple labels works, but I cannot figure out how to make a conditional statement for it.

I tried:

<b:if cond='data:blog.canonicalUrl == &quot;http://www.website.com/search/?q=label:Graphics|label:Identity|label:Brand&quot;'>
    <style type="text/css">
        ...
    </style>
</b:if>

That won't work because of queries in the URL. So then I tried:

<b:if cond='data:blog.searchLabel == &quot;Graphics|Identity|Brand&quot;'>
    <style type="text/css">
        ...
    </style>
</b:if>

That doesn't work, nor does it seem proper. I'd rather have it done in XML, but if I cannot javascript will do. I even tried:

if(window.location('http://www.website.com/search/?q=label:Graphics|label:Identity|label:Brand') === 0)
    document.write("<style type='text/css'> ... </style>
);

BTW, the CSS must be in the doc, not an external source.

like image 673
Xarcell Avatar asked Mar 23 '23 14:03

Xarcell


2 Answers

You can now use:

<b:if cond='data:blog.searchLabel in ["Graphics", "Identity", "Brand"]'>
  <style type="text/css"> ... </style>
</b:if>
like image 64
Taufik Nurrohman Avatar answered Apr 01 '23 10:04

Taufik Nurrohman


You can try do it separately for each tag:

<b:if cond='data:blog.searchLabel == &quot;Graphics&quot;'> <style type="text/css"> ... </style> </b:if>

then

<b:if cond='data:blog.searchLabel == &quot;Identity&quot;'>
    <style type="text/css">
        ...
    </style>
</b:if>

and finally...

<b:if cond='data:blog.searchLabel == &quot;Brand&quot;'>
    <style type="text/css">
        ...
    </style>
</b:if>

make sure you use the exact label with uppercase letters etc!