Showing posts with label Blogger Tips and Tricks. Show all posts
Showing posts with label Blogger Tips and Tricks. Show all posts

Monday, May 3, 2010

Add Scrollbars to Blog Widgets



This tutorial shows you how to create widgets or boxes with
scrollbars. When the contents in the widget exceed a certain specified
height or width, there will be a vertical or horizontal scrollbar to
enable users to read the contents that overflow or exceed the box area.
This scrolling element is especially useful for our Link List or Labels
widget which may be very lengthy. It reduces the total height of the
widget and yet allows readers the option of scrolling through and
viewing the entire content. We shall discuss how to customize the
template design to include the scrollbars and the various modifications
that can be made to the stylesheet.

The “overflow” style property

Let
us first explain what the code is about. We use the “overflow” property
to create the scrollbars in CSS or the stylesheet. There are several
values that can be assigned to it, although not all are useful for our
purposes.

1. overflow:visible

This
is the default value. The extra content is either rendered outside the
box or the length of the box is extended to include the extra content.
Don't bother to use this in Blogger blogs
because you will see the
contents of the widgets overlapped like this:-


Add Scrollbars to Blog Widgets

2. overflow:hidden

This
will cut off the extra content that overflows and there will be no
scrollbar to the box. It doesn't serve our purpose as well.

Add Scrollbars to Blog Widgets

3. overflow:scroll

The content is clipped but there will be scrollbars at the sides.

Add Scrollbars to Blog Widgets

4. overflow:auto

We
like this attribute. Basically, it tells the browser to display a
scrollbar only when necessary i.e., when the content overflows the
width and height settings.

Add Scrollbars to Blog Widgets

Scrollbar in All Widgets

Now
that we know what the code does, we can apply it to our template. If we
have many widgets in our sidebar, we can specify a fixed height for all
the widgets. Carefully planned, our layout can look very neat since all
the widgets will have the same height.

Login and go to Template
-> Edit HTML. Insert this piece of code. For easy reference, we have
added it under the /* Sidebar Content */ :-

/* Sidebar Content */
.sidebar .widget{
height:200px;
overflow:auto;
}


Add Scrollbars to Blog Widgets

In
our example, we applied a height of 200px to the widgets. This can be
changed to other values. Look at both sidebars. Notice the neatness and
symmetry. Be careful though if you have AdSense Ads in the sidebars. It
is against AdSense TOS to cut off the Ads and put scrollbars to their
Ad Units.

Scrollbar in Widgets of One Sidebar

Let
us assume for our discussion that you have modified your template to
include an additional sidebar using our Three Column Template guides.
We may have all the AdSense Ads in one sidebar and we want to add the
scrollbars into the widgets of the other sidebar. The style that can be
inserted into the template will be this:-

/* Sidebar Content */
#newsidebar .widget{
height:200px;
overflow:auto;
}


Or this:-

/* Sidebar Content */
#sidebar .widget{
height:200px;
overflow:auto;
}


depending
on which sidebar your widgets are at. Preview the template and if it is
what you want, save the Template and refresh your Blog.

Scrollbar in One Widget only

We can add the scrollbar only to one or several of the widgets. To do that, we must first know the ID
of the widget. When we are at Template -> Edit HTML, scroll towards
the bottom of the template code. You will see something like this:-

<div id='sidebar-wrapper'>
<b:section class='sidebar' id='sidebar' preferred='yes'>
<b:widget id='LinkList1' locked='false' title='General' type='LinkList'/>
<b:widget id='HTML1' locked='false' title='' type='HTML'/>
<b:widget id='Label1' locked='false' title='Label' type='Label'/>
</b:section>
</div>


In
this example, we have added a Link List Page Element into our Sidebar
and the ID for this widget is “Linklist1”. If we have more link lists,
the IDs will be “Linklist2”, “Linklist3” and so on. Also, we have
inserted a HTML/JavaScript Page Element and the ID is “HTML1”. The
third widget we added is a Label list and the ID is “Label1”. Look at
your template and identify the widget. Take note of the widget ID.

With the ID, we can now add the overflow property into the stylesheet under /* Sidebar Content */:-

/* Sidebar Content */
#Label1{
height:200px;
overflow:auto;
}


Add Scrollbars to Blog Widgets
This will add the scroll-bar to the Labels widget only without affecting the other widgets. Insert the relevant ID of your widget into the portion shown in red.

Scrollbar in All Widgets except One

A
further variation is to add scrollbars to all the Widgets except one or
two. As mentioned earlier, AdSense widgets should not have scrollbars
and it might be your intention to have scrollbars in the rest of the
widgets.

Follow the guide above to insert scrollbars into all
the widgets. After that for the ones that you do not want scrollbars to
appear, specify a bigger value for the height:-


/* Sidebar Content */
#AdSense1{
height:600px;
}


For
example, if your AdSense unit is a 160x600 Vertical Wide Banner, put
the height of the widget as 600px. Since the contents fit nicely into
this size, the scrollbars should not appear. Change the widget ID accordingly to point to the widget that you want to exclude and adjust the height value.

Scrollbar for Links and Labels

We
need scrollbars usually for Label lists and Blogrolls created using
Link lists because these are usually lengthy. You may have noticed that
using the above codes, the entire widget is included in the scroll.
Supposing we want the title to remain static and have a scrollbar only
for the links or labels, we can insert a code as follows (remember to
enter the relevant ID into the part shown in red):-

/* Sidebar Content */
#LinkList1 ul{
height:200px;
overflow:auto;
}


Add Scrollbars to Blog Widgets

Scrollbar for Blog Posts

Should you want the scrollbars for each of your blog posts, scroll to where you see this code and add the portion (shown in red):-

.post {
height:200px;
overflow:auto;
}


Scrollbar for text within Blog Posts

Perhaps
you might not want to have scrollbars for all the Blog Posts, but only
for a piece of text within a Blog Post. You can follow the steps in
this guide to insert scrollbars to text within the post.
Scrollbar for Long Text

If
you have a long piece of text like those found in the usual Terms of
Service, User Agreements, Rules, Privacy Policy, etc., scrollbars will
be very useful in minimizing the text area and yet allowing readers to
view the full contents.
Under Template -> Edit HTML, /* Sidebar Content */ , define a class as follows:-

.scrollingtext {
height:200px;
width:200px;
border:0;
overflow:auto;
}


What
we have done is to specify that the text will be contained in a box
with scrollbars automatically added if the text overflows the 200px x
200px area. The values of the border, height and width can be changed
to suit your needs.

We can now type the text. This text can
either appear in a Blog Post, or as an element in the Template. If it
is in a Blog Post, after you have typed the TEXT in the Post Editor, switch to “Edit HTML” mode and insert these tags (shown in blue):-

<div class="scrollingtext">TEXT</div>


The TEXT
can be inserted directly into the template via Template -> Page
Elements -> Text. Similarly, if you have typed it in the rich editor
mode, you can click the “Edit HTML” link at the top right corner and
insert the above tags.

After publishing the post or saving the page element, you will be able to see the TEXT within a box and the scrollbars automatically inserted.

Adsense Code Converter for Blogger



Have you ever tried to insert javascript ad code directly into your Blogger Template and it just wouldn’t work? Ok, everyone in the room can put their hands down now. This has always been a huge problem for blog authors using Google Blogger looking to monetize their site since almost all ad code contains javascript.

So why is this so darn difficult to do? The problem in the past was that Blogger users wanted more control over where and how frequently their block of ad code (usually AdSense) appeared. The Blogger Team listened to their customers and created an easy to use feature that allows you to setup AdSense in your individual posts with a simple checkbox selection.
Typical Blogger Error Messages

That’s great for most people but the places where you can insert widgets are rather limited and not as flexible as you’d like. So what if you want to put AdSense, AdBrite, Chitika or any other sort of javascript-related code elsewhere on your blog without having to use a widget? The answer in the past would be, “It’s just not easy”.

You would paste the Google AdSense, AdBrite, Chitika or any other javascript ad code into your xml Blogger template only do get an error like:

“Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly. XML error message: The processing instruction target matching “[xX][mM][lL]” is not allowed.”

or another really cryptic error message like:

“Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly. XML error message: The content of elements must consist of well-formed character data or markup.“.

In fact, more recently the Blogger xml parser seems to allow javascript code in your template without displaying an error message at all. You think all is well only to discover when you view your blog that nothing actually gets displayed. Grrr.
So here is the solution ,parse your code according to xml .To get your Adsense code parsed/changed according to Blogger ,paste the Adsense code or whatever adservice you using code here in this below given box and press enter.
And copy the code you will get and paste it anywhere in the HTML Of your blogger template it will run:)

Paste Ad Code to Convert Here:




Add Favicon icon to Blogger URL



Have you wondered how these little icons appear next to the web
addresses, like the one you see above? When you visit the sites or
bookmark them, these icons will make these URLs stand out. These are
“Favicons” or “Favorite Icons”.

You would first need to have an
icon which you would like to use, bearing the extension .ico format. If
you search your hard disk, you might find some icons which are generic.
I would suggest that you create one to represent your own unique
identity. There are quite a number of free icon editor software which
you can download from the net.

As for myself, I went to Download.com site and downloaded a very small program called Imagicon
which can transform images into .ico format. I created an image using
Photoshop. You can use any image or pictures if you do not wish to
create one. Next, run the program. It is rather simple to use. While
you can create icons in 2 sizes – 16x16 and 32x32 – I would think a
16x16 icon is preferable since it is readable in most older browsers.

If
you do not wish to download any software, you may also try creating an
icon online. Just enter the keywords “online icon generator” into your
Google search bar, and you should be able to find several programs that
you can try.
Once
you have created an icon, save it into your hard disk. The next step of
attaching the icon is a little tricky. Ideally, all you need to do is
to save it in the root directory of your blog site. Nevertheless, there
is no way this can be done. For one, if you try to upload an icon
image, Blogger will reject it. Two, any file that is uploaded will not
go into the Blogger root directory.

The only method to use will
be to upload the icon into some web folder, and create a link. You can
read about using free hosts like Google Page Creator and Google Groups. We have also a rather comprehensive list of free Image Hosts and File Hosting Services in our article on Manage Blogger Image Storage Space. Check out those sites and choose one that is fast, reliable and allows uploading of .ico files.
Once
you have done that, take note of the URL of your icon. If you are using
Google Page Creator, hovering your mouse over the link, you will see
that the file is stored under a directory which looks like this http://yourname.googlepages.com/iconname.ico
where “yourname” is your Gmail accountt name, and “iconname” is the file name. Copy this URL.

Go back to your Blogger dashboard and under the Template tab, go to “Edit HTML”. Near the top you will see a line like this:-

Go back to your Blogger dashboard and under the Template tab, go to “Edit HTML”. Near the top you will see a line like this:-

<title><data:blog.pageTitle/></title>


Update:

Copy and insert the following code below the line:-

<link href='URL of your icon file' rel='shortcut icon' type='image/vnd.microsoft.icon'/>


Inserting this will also work but the former is preferred:-

<link href='URL of your icon file' rel='shortcut icon' type='image/x-icon'/>


Remember to type in the “URL of your icon file”.

Save the template. When you refresh your blog site, you should see your nice little Favicon next to the blog address.

Other image types

The
.ico image format has been used by many but you can also create an
image under the .png or .gif format. Ensure that the size of the image
is either 16x16 pixels or 32x32 pixels.

If you have a PNG format image, the link to insert is:-

<link href='URL of your icon file' rel='shortcut icon' type='image/png'/>


If it is a GIF format image, the link is:-

<link href='URL of your icon file' rel='shortcut icon' type='image/gif'/>

External Domain


For
those who have hosted sites in external domains, insert the link in the
root directory as well. Otherwise, you can upload the file into the
root directory and name it favicon.ico

As an example, if your domain name
is www.domain.com, the URL of the favicon will be www.domain.com/favicon.ico

This
method is not preferred but a number of browser versions are able to
process the icon. Since we do not have external domains to try out this
alternative, you may want to see if it works for you.

Compatibility

While
you can see the Favicon in Mozilla Firefox, many have problems seeing
the Favicon in Internet Explorer. This is a known problem and has been
a sore point with many IE users. In some versions of IE, bookmarking
the site will display the Favicon. This is not necessarily so in IE7
that we are using. In fact, when we bookmarked the highly popular
search engine sites, their Favicons don't show in our IE bookmarks too
although they show well in Firefox. Perhaps this is one more reason to
download Mozilla Firefox if you have not already done so.
free counters