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 == "http://www.website.com/search/?q=label:Graphics|label:Identity|label:Brand"'>
<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 == "Graphics|Identity|Brand"'>
<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.
You can now use:
<b:if cond='data:blog.searchLabel in ["Graphics", "Identity", "Brand"]'>
<style type="text/css"> ... </style>
</b:if>
You can try do it separately for each tag:
<b:if cond='data:blog.searchLabel == "Graphics"'>
<style type="text/css">
...
</style>
</b:if>
then
<b:if cond='data:blog.searchLabel == "Identity"'>
<style type="text/css">
...
</style>
</b:if>
and finally...
<b:if cond='data:blog.searchLabel == "Brand"'>
<style type="text/css">
...
</style>
</b:if>
make sure you use the exact label with uppercase letters etc!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With