18 February 2008

Background Image for Blogger Template

With this guide, you will be able to
1. add a background image or picture to entire blog or to the posts only or to your sidebar only.
2. add a static background image that stays in place when you scroll through the contents of your blog.
3. customize the position of your image.

All you need to have is an image readily hosted in some image-hosting websites like flickr, picasa or any picture that you'll find on the net(googling).
Goto your image hosting site and take note of the picture URL.
Next, log in to your Dashboard click Layout and click Edit HTML, and search for the following code in the code window;
body {
background:$bgcolor;

and add the following code;
body {
background-image: url(URL address of your image);

Remember to insert the URL address of your image in the brackets.
Insert the URL of your image in the above brackets and Click Preview to see the feel of your blog.
If you like the page feel, save the template.

Background for sidebar:
You can also have a background image just for your sidebar. Locate the following code-snippet and add the background image code accordingly.
#sidebar-wrapper {

#sidebar-wrapper {
background-image: url(URL address of your image);

Background for posts:
For a background image to your main post body only, find the code-snippet #main-wrapper { and add the background-image code like the way I've done below;

#main-wrapper {
background-image: url(URL address of your image);

Repeating background image:
By default, the image is repeated to fill up the entire background of the page. If you have a small or tile-sized image, it will appear like a print pattern in the background. Sometimes, you dont want to have the image repeated. In such cases add the following code snippet in the place where you have added the above mentioned code;
background-repeat: no-repeat;

Alternatively, to repeat the image horizontally. The code is;
background-repeat: repeat-x;

To repeat the image vertically, the code is;
background-repeat: repeat-y;

Positioning background image:
If you dont want your image to be repeated and you want to specify the exact position of this image on your page, the code that to be inserted is;
background-position: top left;

The image will appear at the top left corner of your page. The other possible values that you can use to replace 'top left' are;
top center;
top right;
center left;
center center;
center right;
bottom left;
bottom center;
bottom right;

If you do not want it entirely left, right or center, you can also define the horizontal and vertical alignments either in percentage or in pixels. Use either of these values instead, with x being the horizontal value and y being the vertical value.
x% y%;
xpx ypx;

Static background image:
You can also make the background image to remain in a fixed position when the contents of your blog are scrolled. By default, the picture scrolls with your content. To make image pinned down while your text scrolls, the code you have to add is;
background-attachment: fixed;


Putting everything together
The final code that you will have for your customized template after altering according to this guide would look like;
body {
background-image: url(image url);
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;

You can also combine the attributes into one line and the shorthand code will look like;
body {
background: url(image url) no-repeat center center fixed;

Removing the sidebar from your template

1. Go to Dashboard.
2. Click on Layout of the blog for which you want to remove the sidebar.
3. Click on Edit HTML.
4. In the template code, search for #main-wrapper code, which will look like this:
#main-wrapper {
width: 410px;
float: $startSide;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}
5. Remove the entry width: 410px; and save the template by clicking SAVE TEMPLATE.
6. Voila! you are done.

17 February 2008

Adding widgets everywhere

Go to Dashboard, choose your blog and click on Layout. Click on Page Elements. Now click on Add Page Elements. A new window appears which shows the page elements. Choose the type you want to make and click on it. This opens a new window where the new Page Element is shown ready to accept your data. Do not enter any data at present. Choose Save and the window closes after adding the Page Element to your blog.
Now click on Edit HTML tab under the Layout. Put a checkmark in Expand Widget Templates checkbox. This expands the template HTML widget code. Beta Blogger is arranged in Sections called Header, Sidebar, Main and Footer. Each section can contain one or more Page Elements/widgets. The code for each section is enclosed in tags similar to:

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

Above code is for the Header section. If you want to add a page element to this section, make the changes as; maxwidgets='2' and showaddelement='yes'. Save the Template.

Template tweaking process

Learning how to hack the beta blogger template will help you making your blog customized and unique across blogosphere.
Beta Blogger Templates are made of XML/XHTML. There are five main parts to the template as described in Parts of the Template.

The CSS in the beta Blogger are :
body
outer-wrapper
wrap2
header-wrapper
header section
content-wrapper
main-wrapper
main section
sidebar-wrapper
sidebar section
footer-wrapper
footer section

A simple approach to hack the template is to delete the XML declarations and add <style> tags and then load them into any web editor. This also has its drawbacks as beta blogger may not recognize and accept them in certain cases.
But the best approach is to use the facilities provided by Beta Blogger itself. To use this approach follow these steps :

* Login to Dashboard and select Create a Blog.
* Create a blog with any name and post/publish it.
* Go to Pick New Template subtab under Template tab.
* Pick the Template which most closely resembles the design you have in mind.
* Save Template.
* Go to Edit HTML subtab under Template tab.
* Save the default template in your machine by clicking Download Full Template link.
* Scroll down in Edit Template text box.
* Look for the code you want to change.
* Click on PREVIEW at bottom to see the effect of the change.
* If you like the change click on SAVE TEMPLATE, else click UNDO to discard the changes.