Close

×

Tutorials

Blogger Tutorial

Start Blogger

Templates

Blogger Templates

Recent Post Popular Post Featured Post Related Post

nayan ad

Share


Like
×

Top Navigation Menu

×

Search v5Blogger

Powered by Google

Blogger <b:switch> Tag

Use b:switch tag to insert multiple b:elseif like tags.
  • Don’t need to repeat the variable name.
  • Easily read variables to see what defines each case, and what the default case is.

HTML b:switch Syntax

Each Blogger Loop in your template has opening and closing tags.

<b:switch var='Data Expression'>
<b:case value="Value1" />
 Display if Value1 is equal
<b:case value="Value2" />
 Display if Value2 is equal
<b:default />
 Display if not equal to any other b:case
</b:switch>
b:case tag can be repeted as need.

Usage of b:switch Tag

Go to Template > Edit HTML.

Blogger Section: new

<html>
<head>
<title><data:blog.pageTitle/></title>
<b:skin/>
</head>

<body>
<b:switch var='data:blog.pageType'>
<b:case value="static_page" />
  <h1>Page</h1>
<b:case value="item" />
  <h1>Post</h1>
<b:default />
  <h1>Blog Posts</h1>
</b:switch>

<b:section id='new'>
  <b:widget id='Blog1' type='Blog'/>
</b:section>

</body>
</html>

Post

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

HTML b:switch Attributes

Attribute Values Description
var name Defines Data expression name.

HTML b:case Attributes

Attribute Values Description
value name Defines Data expression value.

Footer Note

v5 Blogger is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2016. All Rights Reserved.
Powered by W3.CSS.

v5 Library