• Problems

    This line enable URL Rewriting . It must be enabled via the RewriteEngine directive! and if your .htaccess file is going to use rewrite rules, you should always include this line. Otherwise, you can’t be sure if its enabled or not. The string “on” is case insensitive.

When to use if, elseif, or else

You can use the b:if, b:elseif and b:else tags to display certain content in particular cases, and other content in other cases. For example, you might only want to show certain text on the homepage, but different text when looking at individual posts.
Format



<b:if cond='condition'>
  [content to display if condition is true]
<b:elseif cond='another condition'>
  [content to display if no previous if or elseif conditions have been true, and this elseif condition is true]
<b:else/>
  [content to display if no if or elseif conditions are met]
</b:if>



The b:elseif and b:else tags are optional. Without them, the result will be either the content listed in the b:if section or nothing. The closing </b:if> is required in each case, however.

For "condition" you can put in anything that evaluates to either true or false. Some data tags are simply true/false values on their own, e.g. allowComments on a post. With other pieces of data, you can compare them with specific values to get a true or false. Here are some examples:

    <b:if cond='data:post.showBacklinks'>
    True if the current post is set to show backlinks.
    <b:if cond='data:blog.pageType == "item"'>
    True if the current page is an item page (post page).
    <b:if cond='data:blog.pageType == "item" and data:post.showBacklinks'>
    True if the current page is an item page (post page) and the current post is set to show backlinks.
    <b:if cond='data:displayname != "Fred"'>
    True if this is not Fred's display name.
    <b:if cond='data:displayname == "Fred" or data:blog.pageType == "static_page"'>
    True if Fred is the display name, or the current page is a static page (not a post page).
    <b:if cond='data:post.numComments > 1'>
    True if the current post has more than one comment.
    <b:if cond='data:blog.pageType in {"static_page", "item"}'> OR <b:if cond='{"static_page", "item"} contains data:blog.pageType'>
    True if the current page is a specific post, or a page.

Switches (b:switch)
When to use a Switch

You can use b:switch tag much like you would use a b:if tag that has several b:elseif tags. The advantage of a switch branch is that you don’t need to repeat the variable name. You can easily read them to see what defines each case, and what the default case is.
Format

<b:switch var=’[Data expression]’>
<b:case value=”[Value 1]” />
 [Output if evaluation of var is equal to Value 1]
<b:case value=”[Value 2]” />
 [Output if evaluation of var is equal to Value 2]
[… any other values]
<b:default />
 [Output if evaluation of var is not equal to any other stated b:case]
</b:switch>
Example

This example shows how to output a different header, depending on what type of page is being rendered.

<b:switch var=’data:blog.pageType’>
<b:case value=”static_page” />
  <h1>Page</h1>
<b:case value=”item” />
  <h1>Post</h1>
<b:default />
  <h2>Blog Posts</h2>
</b:switch>

No comments:

Post a Comment