With any condition you have a true, false and equal value.
Example:
Sunday is a weekend!That statement is true!
The basic variables you would see in a conditional statement are:
== Equal to.
!= Not Equal to.
=== Exactly Equal to.
There are more but those are the basics that you will use for most conditional statements.
If we were to write a conditional statement into a text sentence it may looks something like this.
If today is Sunday I will go to church.This is a conditional statement saying "I will go to church if today is Sunday".
This condition is "If today is Sunday"
The action if the condition is true (met) is "I will go to church".
I could also write it like this below.
Day of week == SundayHowever this is not a proper code to put in your template because statements need to be recognized and day of week and Sunday are not recognized without more coding to retrieve the date from the users computer.
I will go to church.
Their are universal codes and tags that will be recognized without any farther coding needed. I will go over a few below.
I have equal to variables in all these below but they can be changed to != (Not Equal) as well.
- Homepage
<b:if cond='"data:blog.url == data:blog.homepageUrl"'>
<style>
<--Content to be displayed on homepage only -->
</style>
</b:if>
<style>
<--Content to be displayed on homepage only -->
</style>
</b:if>
- Static Pages
<b:if cond='data:blog.pageType == "static_page"'>
<style>
<--Content to be displayed on static pages only -->
</style>
</b:if>
<style>
<--Content to be displayed on static pages only -->
</style>
</b:if>
- Post Pages
<b:if cond='data:blog.pageType == "item"'>
<style>
<--Content to be displayed on static pages only -->
</style>
</b:if>
<style>
<--Content to be displayed on static pages only -->
</style>
</b:if>
- Specified Page
<b:if cond='data:blog.url == "Blog Post URL"'>
<style>
<--Content to be displayed on specified page only -->
</style>
</b:if>
(In the example above you must fill in the Blog Post URL with the URL of the page or post your choosing.)<style>
<--Content to be displayed on specified page only -->
</style>
</b:if>
Learn About Conditional "Else" Tags.
2 comments:
Hello. I'm wondering if conditional tags could be applied to opening links in an external window in combination with this tweak:
...expr:href='data:link.target' target="_blank">...
Specifically, can a conditional tage be used to open only external links in a new window? Such as, if the target domain is different from the source domain perhaps?
Hmmmm that would be a interesting way to use conditional tags! I am not aware of anyway to do so with these conditional tags. Their might be some JavaScript conditions that will allow you to do so but I am not a JavaScript programmer. I would recommend looking around on this site. If you can find it then sign up for the forums which will take a few days to be approved because they are privet forums. The forums on that site have many experts who can help.
Post a Comment
Please don't post hyperlinked text within the comment box! It will not be published and you will be marked as spam.