Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
I had to
search around a lot of websites and did a lot of googling to find out how to build a complete
blogger template. Turns out it is pretty easy to build it yourself, but you need to know some
stuffs before hand. The thing is, you need to understand how it works and should have an
idea of how your blog should be.
When we submit the template XHTML code to the blogger it is stored in the blogger
database. When the blog is requested via a browser, the Blogger Parser parses the
code and sends back the HTML output of the parsed XML code which will be
displayed in the browser.
Blogger template is fully coded in XHTML and Blogger Elements. In the above code
we have defined a set of xmlns (XML Namespace) which are defined by Google for
use with blogger. Namespace such asxmlns:b, xmlns:data, xmlns:expr lets us
design our blogger web page and also to get data from the blogger database.
Note: You can change the above namespace name from b to blog or data to d at
anytime. But its best to stick with what is default.
Section
The Blogger template layout is designed with Sections. Sections are the ones which
makes the layout of the web page(like header, footer, sidebar etc.). It is like the
sections in HTML5.
Sections in blogger
Above image shows some sample web page layouts which will give you an idea of
what a section of a web page might be.
Section Syntax
The syntax to create a section in blogger is shown below. There can be any HTML
code around the section code, but there can't be any HTML inside the section code.
To define the contents of the section we must use the Widget element in blogger,
which will be discussed shortly.
Each section tag has the following syntax, which is similar to an HTML element with
attributes.
<b:section id='' class='' maxwidgets='' showaddelement=''>
</b:section>
Each attributes have different meanings, that will be parsed by the blogger to render
the elements final output.
Section Attributes
Example Code
<b:section id='header' class='header' maxwidgets="1" showaddelement="no">
<!-- Section contents -->
</b:section>
<b:section id='main' class='main' maxwidgets="1" showaddelement="no">
<!-- Section contents -->
</b:section>
<b:section id='footer' class='footer' showaddelement="no">
<!-- Section contents -->
</b:section>
Note: By default there must be at least two b:section tags or else blogger will throw
an error.
Widget Tags
Sections are made mainly using widgets. Sections are just layout elements, widget is
with which the real data is displayed. A widget at its simplest form, is just a single
tag, which is a placeholder for what should appear in the page element. There are
some default widgets available in blogger and a custom widget can also be created.
The data for the widget is stored in the blogger database and is accessed only when
the widget is to be displayed.
Widget Syntax
<b:widget id='' locked='' mobile='' title='' pageType='' type='' />
id(Required) - 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.
o
o
o
o
o
o
o
o
o
o
o
o
o
BlogArchive
Blog
Feed
Header
HTML
SingleImage
LinkList
List
Logo
BlogProfile
Navbar
VideoBar
NewsBar
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.
Example Code
<b:section id="sidebar" class="sidebar" maxwidgets="" showaddelement="yes">
<b:widget id='CustomSearch1' title='Search' type='CustomSearch' locked='false'/>
<b:widget id='FollowByEmail1' title='Follow By Email' type='FollowByEmail'
locked='false' />
<b:widget id='PopularPosts1' locked='false' title='Popular On Relatemein'
type='PopularPosts'/>
<b:widget id='Label1' type='Label' locked='false' />
</b:section>
The Syntax and Documentation is taken from the Official Blogger Documentation
The basic <b:widget/> tag was explained in part one of Blogger Template Design
from Scratch. In this post, there will be a detailed description of how widget tag can
be used to have a fine grained control of what appears inside of the widget.
The basic form of the widget tag contains a self closing tag with the attributes related
to it.
<b:widget [attributes...] />
You can consider these basic widget tags like function invocation, whereas the
definition of the function is present in blogger.
Expand widget
Most of the widget types specified in the previous post are defined by blogger. To
create custom content in the widget, use the HTML type.
Example:
<b:widget id='HTML1' type='HTML'>
</b:widget>
Note: For the id of the widget, its best to provide the id of format - {type}{digit starting
from 1 for each widget}. For example, if a custom contact and labels widget is
created, their respective ids would be HTML1 and HTML2 with type HTML.
Includable Syntax
Includable
Includable Attributes
Include
Includes are used if you have a section of code that you want to repeat multiple times
in different places. When a include is used, that particular include is replaced with the
contents of the includable.
Example
<b:includable id='main'>
<b:loop var='i' values='posts'>
Include Syntax
<b:include name=idOfTheIncludable data=dataForIncludable />
Include Attributes
Default Includable
Every custom widget must contain a includable with id equal to main(main
includable). This main includable will contain the content for entire the widget. Infact,
this is the only includable you need to specify the contents of the widget. If you need,
you can define more includables inside the widget and outside the main includable,
and include it inside the main includable using the include element.
Even if you have more includables with different ids it will not be displayed
automatically in the widget. You need to specify it inside the main includable using
the include element with reference to the includable id.
Dodle: If you have experience in C Programming, there will be a main() function that
will be called first for the start of the program execution. Consider the main
includable(id=main) as the main() function in C Programming for the widget.
Example:
Widget
You can place the above widget code in your blogger template to view the output.