Blogger Widget : Page Elements Tags for Layouts

The <body> section of a Layouts template will be made up primarily of sections and widgets. Sections mark out areas of your page, such as the sidebar, the footer, etc. A widget is an individual page element such as a picture, a blogroll, or anything else you can add from the Page Elements tab. You can include any HTML you like around the sections in your template.

Each section in your template will have an opening and a closing tag, looking something like this:

<b:section id='header' class='header' maxwidgets="1" showaddelement="no">

</b:section>

A <b:section> tag can have the following attributes:

  • id - (Required) A unique name, with letters and numbers only.
  • class - (Optional) Common class names are "navbar," "header," "main," "sidebar," and "footer." If you switch templates later, these names help Blogger determine how best to transfer over your content. However, you can use different names, if you like.
  • maxwidgets - (Optional) The maximum number of widgets to allow in this section. If not specified, then there is no limit.
  • showaddelement - (Optional) Can be "yes" or "no," with "yes" as the default. This determines whether the Page Elements tab will show the "Add a Page Element" link in this section.
  • growth - (Optional) Can be "horizontal" or "vertical," with "vertical" as the default. This determines whether widgets within this section are arranged side-by-side or stacked.

In your published blog, all <b:section> tags will be replaced with <div> tags, which will have the specified ID. So you are welcome to refer to, for example, div.header in your CSS if you want to.

A section can only contain widgets; it cannot contain other sections or other code. If you need to insert extra code between or around certain widgets within a section, you'll need to split the section into two or more new sections.

In its simplest form, a widget is represented by a single tag, which is basically just a placeholder indicating how the widget should be handled in the Page Elements tab. The actual data for any given widget is stored in the Blogger database and only accessed when the widget needs to be displayed. Some examples of widgets (one for a page header and one for a list) are the following:

<b:widget id="header" type='HeaderView' locked="yes"/>

<b:widget id="myList" type='ListView' locked="no" title="My Favorite Things"/>

A widget may have the following attributes:

  • id - (Required) This may contain letters and numbers only, and each widget ID in your template should be unique. A widget's ID cannot be changed without deleting the widget and creating a new one.
  • type - (Required) This indicates what kind of a widget it is, and should be one of the valid widget types listed below.
  • locked - (Optional) Can be "yes" or "no," with "no" as the default. A locked widget cannot be moved or deleted from the Page Elements tab.
  • title - (Optional) A display title for the widget. If none is specified, a default title such as "List1" will be used.
  • pageType - (Optional) Can be "all," "archive," "main," or "item," with "all" as the default. The widget will only display on the designated pages of your blog. (All widgets display on the Page Elements tab, regardless of their pageType.)

The types of widgets you can specify are:

  • BlogArchive
  • Blog
  • Feed
  • Header
  • HTML
  • SingleImage
  • LinkList
  • List
  • Logo
  • BlogProfile
  • Navbar
  • VideoBar
  • NewsBar

Each widget can also be written out in an expanded form, detailing the complete layout and contents for that widget. This is what you'll see, for instance, if you download your template from the Edit HTML tab to make a backup. Usually, you won't need to work with widgets in this mode, since it's simpler to just modify them from the Page Elements tab. However, if you want to know more, you can read about the detailed widget tags.

Note: In your published blog, all <b:section> and <b:widget> tags will be replaced with <div> tags, which will have the specified ID. So you are welcome to refer to, for example, div#header or div#myList in your CSS if you want to.

1 people have left comments

alhoseany said:

hi, i want to know how u fixed the problem of adding new widgets to this awesome blog template.
plz help me about that.

Commentors on this Post-