Table Of Contents Widget For Blogger


You might have noticed the new Table Of Contents Section On this Blog.. It uses the Selective Widget Display.. This widget requires Javascript ans hence it will take time to load.. So we will be modding it so that it will be displayed on a particular Page only..

Demo of TOC
Here is the Step by Step Tutorial
1.Make a new Blank Post in Blogger With Title "Table Of Contents" (or whatever you like)
2.Before publishing this post,make sure that you set the publishing date to an old one so that this post wont appear in your blog feed..You can Do it From Post Options in the Post Editor.. Also Don't allow comments on this post

3.Now we have created a new post page where the Table Of Contents will be displayed

4.Note down the URL of this post that we created
5.Find
</head>
in your template and replace it with the following code after applying the proper url

<b:if cond='data:blog.url == &quot;http://www.bloggerplugins.org/2005/06/table-of-contents.html&quot;'>
<style>

#toc {
border: 0px solid #000000;
background: #ffffff;
padding: 5px;
width:100%;
margin-top:10px;
}
.toc-header-col1, .toc-header-col2, .toc-header-col3 {
background: #ddd;
color: #000000;
padding-left: 5px;
width:50%px;
}
.toc-header-col2 {
width:15%;
}
.toc-header-col3 {
width:25%px;
}
.toc-header-col1 a:link, .toc-header-col1 a:visited, .toc-header-col2 a:link, .toc-header-col2 a:visited, .toc-header-col3 a:link, .toc-header-col3 a:visited {
font-size:93%;
text-decoration:none;
}
.toc-header-col1 a:hover, .toc-header-col2 a:hover, .toc-header-col3 a:hover {
font-size:93%;
text-decoration:underline;
}

.toc-entry-col1, .toc-entry-col2, .toc-entry-col3 {
padding-left: 5px;
font-size:93%;
}
.post{display:none;}
.comments-block{display:none;}
.comment-form{display:none;}
.comment-footer{display:none;}
.blog-pager{display:none;}
.date-header{display:none;}
.feed-links{display:none;}
.comments{display:none;}
</style>
</b:if>
</head>

6.Now again edit your template.. Don't Expand the Widget Templates..
7.Find this line of code


<b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'/>

and immediately after that place this code snippet..(after editing the snippet with your toc url)
<b:widget id='HTML345' locked='false' title='Table Of Contents' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == &quot;http://www.bloggerplugins.org/2005/06/table-of-contents.html&quot;'>
<h2 class='title'>Blog Table Of Contents</h2>
<div class='widget-content'>
<div id='toc'><img src='http://i38.tinypic.com/34ov7n4.gif'/>Loading The Blog TOC...</div>
</div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>


8.Now Find
</body>

and place this code immediately above it after tweaking it with your blog urls..(there are 2 urls..replace all those green urls properly)
<b:if cond='data:blog.url == &quot;http://www.bloggerplugins.org/2005/06/table-of-contents.html&quot;'>
&lt;script style=&quot;text/javascript&quot; src=&quot;http://blogger-plugins.googlecode.com/files/blogtoc.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://www.bloggerplugins.org/feeds/posts/default?alt=json-in-script&amp;max-results=500&amp;callback=loadtoc&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://www.bloggerplugins.org/feeds/posts/default?alt=json-in-script&amp;start-index=501&amp;max-results=500&amp;callback=loadtoc&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://www.bloggerplugins.org/feeds/posts/default?alt=json-in-script&amp;start-index=1001&amp;max-results=500&amp;callback=loadtoc&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;showToc();&lt;/script&gt;
</b:if>


Now try visiting your TOC Page.. Got it working?? If you failed.. don't worry.. i can help you out..Contact me @ Blogger Forum or via comments
Credits:Special Thanks to Hans of Beautiful Beta for the javascript that powers the TOC
If you got it working show us the url.. We will help you in any further tweaking and let you know if any changes are needed...

Note:If you are reading this in a feed reader, the iframes wont be properly displayed so visit the actual post @ Table Of Contents For Blogger
91 comments: Add Comment
vinoth said...

Question :1

I don't understand what is a table of content....first please give me the screen shot of a toc...then i will try this.....

Question:2

If i link urs footer logo...will u link mine blog in ur blogroll....

Aneesh said...

see the demo..

and if you need a listing here,you can add your blog to our blogger directory

Fa.Topeng said...

its hard away,,better preview with the video
TSF

Aneesh said...

@Fa.Topeng i am not good at making videos.. do u know of any s/w that helps in doing it easily..

Moviesatrapid.com said...

I dont see it working on my blog, can you please check, link is in my name

Aneesh said...

@Moviesatrapid.com you did the first part correctly.. but made a little error on the second one..i had asked to put the last code above </body>
you placed it below it.Change this and you will get the TOC working..

your blog has many posts.. so you will have to add some more lines of code..This by default will show only the first 500 posts..

In this code there are three script lines right?
The second one script line specifies your blogger feed.. Inorder to display the next 500 posts.. you have to put that loine once again, with an additional parameter start-index=501
I have modded the new code in the post .. so take another look..

Mark Glenn said...

what do you think is wrong with mine?It does't appear aneesh!help. .

Aneesh said...

@show me the TOC post page.. I couldn't find it from your big list.. ;)

Yodz said...

hi I tried this, but I'm getting this error message "The template could not be parsed as it not well formed..... The reference to entity "http:" must end with the ";" delimeter.
I'm really no into XML.

and in instruction Number 8 you mentioned 2 url. I found the first one, which is the other one?

Thanks, and more power. I love u.

Yodz said...

opps I forgot my TOC post page, here it is:

http://yodi967.blogspot.com/2004/05/table-of-contents.html

the actual error message is

"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 reference to entity "http:" must end with the ';' delimiter.

Aneesh said...

i think you did the first part correctly..

and you shouldnt be getting an error on step 2..

did you get the error when you tried to place it above </body> ???

Yodz said...

hello, sorry for bugging you, but I finally solve the problem with the delimeter error. I saved my template but It's not appearing.
here's my TOC link

http://yodi967.blogspot.com/2004/05/table-of-contents.html

Thank you so much for sharing this. Hope you can help me out. i love you. more power!

Aneesh said...

ok.. i think you have some problem in the bif condition.. because the the code within

<!--START OF TOC CODE 3-->
<!--END OF TOC CODE 3-->

doesnt appera in the toc page.. had you replaced my toc url??

krease said...

mine seems to just keep loading

http://playstationbloggeruk.blogspot.com/2009/07/list-of-posts.html

Aneesh said...

@krease you changed the script url with the url of your blog..

http://bloggerplugins.org/me/blogtoc.js shouldn't be changed..Its the script that works behinf the TOC.. The loading thing will automatically disappear when this script is executed..

krease said...

thanks very much for your help

any ideas of how i can add a button next to my home button saying list of blogs?

Aneesh said...

that button is an image.. SO you will have to design a similar button using photoshop or gimp..
<a ------><img src="http://img268.imageshack.us/img268/586/hm2.gif"/></a>

Some code similar to this is there in your template.. Add another piece of this code after modifying it with the url and the url of the image..

krease said...

ok thanks

i just noticed in my list every post appears twice is there something i need to change?

Aneesh said...

sorry that was my mistake.. there is some spelling mistake in the code.. ;)

change iindex to index.. :)

krease said...

great thanks very much for all your help

your amazing :)

Yodz said...

I already placed the code in your instruction Number 8. I changed the URL
http://www.bloggerplugins.org/2005/06/table-of-contents.html

into my URL:
http://yodi967.blogspot.com/2004/05/table-of-contents.html

The instruction said there's 2 URLs, I don't know which is the other one.

It is appearing on my EDIT TEMPLATE HTML page when I checked inside blogger, but it's not showing up when I checked view page VIEW -> PAGE SOURCE

The page just keeps on loading blog TOC.

Thanks a lot. More power to you!
You're great.

Aneesh said...

the other url is http://www.bloggerplugins.org/feeds/posts/********

there is 3 occurances of this url..

Yodz said...

Whooah!, I finally got it working.. a million thanks! I will definitely put your link in my blogs.
http://yodi967.blogspot.com/2004/05/table-of-contents.html

hmmm, but one more thing please,please please... I need tweaking in the LABELS column. it's a bit too wide.
[I guess I badly need enrolling a short course on HTML.]
Thanks. I LOVE YOU!

Aneesh said...

use this as the last line in the top css that you added ie just below the </style>

to set width of the third colum.. add this line it is in %
.toc-entry-col3,.toc-header-col3{width:10%;}

to hide the 3rd column add this line

.toc-entry-col3,.toc-header-col3{display:none;}

above</style>

ok ;)

Yodz said...

Got it all nice and neat.
Thanks.
Mabuhay! (that's "Long Live!")
from the Republic of the Philippines.

Aneesh said...

if you want you can change the background color using CSS

just add

background-color:#ffffff; to the #toc definition

where #ffffff is the desired background color in hex..

vinoth said...

thank you for showing a screenshot and a working demo..i will try to implement it..

suman sunkara said...

http://www.visadocumentation.com/2009/06/contents.html
it doesnt work for me please help aneesh
summybabu@gmail.com

al-basri said...

thank for information....

The Doc said...

you are awesome

irfanibnmuhammad said...

I tried and followed all the steps but i am not able to paste the last link in the final code. Where do you i paste 2 urls as you have instructed us to do in the code.

I could figure out the first but not the second one. Your help is appreciated

Aneesh said...

you have to change http://www.bloggerplugins.org/2005/06/table-of-contents.html to your toc page's url

and you have to change http://www.bloggerplugins.org/feeds/posts/default with
http://yourblog.blogspot.com/feeds/posts/default (there are three of them in the code..)

i hope it is clear now..

The King Khan said...

hey man what happened no trick of urs is working on my blog

the above also is not working
plz check the url

http://vaseemansari.blogspot.com/2009/08/table-of-contents-of-vaseemansaris-blog.html

Aneesh said...

@The King Khan as i said for the other one,
follow the tutorial completely..

i cant be sure but i think you diddn't replace
http://www.bloggerplugins.org/2005/06/table-of-contents.html

with
http://vaseemansari.blogspot.com/2009/08/table-of-contents-of-vaseemansaris-blog.html

you might also have missed out on some more.. fix this first.. and i will try to tell you where else you have gone wrong..

David Bergeron said...

Aneesh, nice:) I set it up here: http://www.poker006.com/2009/02/table-of-contents.html

Do you know how I can remove related posts, add in between posts from the table of contents post? And is it possible to split it up into more then 1 page because I have 330 posts and it takes long to load. And someone with 1000 posts will take forever...Anyway, you rock:)

Aneesh said...

first of all its not my hack.. it was made by Hans of Beautiful Beta.. He is no longer blogging.. almost left over..

Yea it is possible to hide the Recent posts thing..you just need to add some more css
try adding .related_posts{display:none;} near the other display nones
to hide the div with id related_posts

and yea its possible to split it up into pages..
say 100 on the first,next 100 on the second..etc.
you will have to make some more toc pages like toc1,toc2 etc.. and do the same for all the pages..

those three lines which contain the feed url decides which ones are to be displayed on each page(something like (http://www.bloggerplugins.org/feeds/posts/)
if you are splitting it up, just use a single instance of that and use start-index and max-results attributes to tweak it around..

i hope you can figure that out..

the max-results that can be fetched at a time is 500, thats y i included 3 instances of that so that it can handle upto 1500 posts..

YOPOP said...

Very nice tutorial.. thanks, one question how did you put your ads in the center of the post.. i can only add before and after post.. thanks in advance

AboutBlogger said...

Thanks i need that table of content widget its nice working
cheers

amigodcristo said...

HI Anesh sorry ,my inglish isnt good, but i will try.. i have done all the steps on the tutorial,but my toc just keep loanding, dosent answer the toc, please help ,,im follow all the coments and i couldint not see why it wont work,many thanks heres the url,,http://amigodcristo.blogspot.com/2009/04/todo-conteudo.html ,,i want to say that is great widget i realy want to have this one..please !!!

Aneesh said...

i think you are modifying it now.. everything is going good!!

but it is http://amigodcristo.blogspot.com/feeds/posts/
and not
http://amigodcristo.blogspot.com/posts/

amigodcristo said...

Aneesh ,,yuopp you are just amazim,,i cant describ you..just superr star,,hehehe many thanks,
,,and congratulation for you job thats you are doing here ,,well recomend cherrs

SBA said...

A table of contents is handy to have when searching for older posts to link to or refer to friends... I have a variation of this tutorial, also based on Hans' work. I like that my TOC is able to sort by clicking the header column. thanks for your version --- variety is the spice of life!

aR said...

Thanks, I will try it in my blog tomorrow.

aR
Bangla Hacks

Abu Farhan said...

You can try my script to make Table of contents, Auto catogorize by label in here The Best Table of Contents (TOC) or Sitemap for Blogger

aR said...

At last I have successfully add it in my blog. Thank you Aneesh. But why don't you write a another tutorial about split it up into more then 1 page.

हिमांशु । Himanshu said...

Excellent. I've also done it. It is strange because I am always terrified for changing or editing the HTML codes.

Thanks.

Whimsical said...

Great hack, awesome stuff! Thank you :-))

aR said...

Aneesh, I implement this in my xxxx.blogspot.com blog successfully. But now I failed to active it in my own domain. Don't know what's the problem. Would you please check my blog?

www.banglahacks.com (Sorry if you think it spamming)

aR said...

I have done. Don't need to publish my previous comment.

Thanks

GunGz - Ponseli said...

Very Great!! I have implement this Blogger Mod.
Much thanks to this blog webmaster!

For others who look for implementation demo, feel free to visit my blog.

Thank You.

Ravis Blog Net said...

I've more than 5 blogs(with subdomains). I want to have a all the posts in various blogs to appear in my main blog. Is there any way we can stream the posts or feeds to my main blog

Inner Voice said...

Its really cOOl i found it working for the very first attempt.


I am searching for a new Hack.How can we show latest posts from a particular Label like recent post widget but only from one label.I hope i m not the only one searching a thing like this:)
thanks

bye...

Aneesh said...

@Inner Voice,
its already there.. you can get that by slightly editing the codes for any of my recent posts widget on this blog. You will have to edit the widget content with the blog's label feed url instead of the blogs feed url..

Mr.Awesome said...

not working...showing a alert box -"Just wait... TOC is loading"

check once :http://123tina.blogspot.com/2005/10/table-of-contents.html

Aneesh said...

@Mr.Awesome ,
i see that its working perfectly now.. hope you fixed it :)

Unity Bond said...

It takes hours for it to load, what have ii done wrong? http://unitybond.blogspot.com/2001/01/contents.html

Aneesh said...

@Unity Bond ,
you didn't do step 8 properly..

Unity Bond said...

Thanks a billion! It worked! Except that its annoying cause got Disqus comment form below which i have no idea how to exclude it from that post. But yeah! I'm glad i found this blog! Thanks again!

Joana Morais said...

I was able to implement it here joana-morais.blogspot.com/2006/09/table-of-contents.html, however I'm having a silly [newbie] problem, how do I change title class? If I replace h2 with h1 the tile will become huge, can we style the title at the css part? If so can you please teach me what to add? thank you.

Ubi Keledek said...

its fail for me,..see http://helpacademy.blogspot.com/2009/08/site-map.html

Bahadırhan said...

There is problem. http://www.gitarevi.net/2009/08/arsiv.html

Unknown said...

this is the url of mine
http://piczzmania.blogspot.com/2008_12_01_archive.html
i did try to do this. but the problem is contents are showing below the post. plz have a look and suggest what can i do thanks.

Janardhan Raju said...

Hi aneesh............

Not working for me........

www.123friendz.blogspot.com.This is my blog.......

So i removed ur code..........

FFL said...

http://blog.imobiliario.com.pt/2009/10/resumo.html

Aneesh

Hi. My page just shows "Loading the Blog TOC"
Can You help me? Thanks

--------------------------------------
Note: On Step 3 I didn't find the line of code:


So I place de code after the line
--------------------------------------

May be is wrong here, no?

Thanks in advance for your help.
GReat work You are doing here.
Regards,

Ms Hetal Patil said...

Hello,

I successfully placed above codes but found the widget placed below the posts area, kindly help........

Glenn said...

i just got this hack into my blog and cannot thank you enough. It worked like a charm (as long as I followed your directions to the letter). I will continue to turn to you for the bets tips and tricks this side of Google. Thank you again.

Glenn
Bigezbear

hdhieu said...

Hi, Could you please help. I have installed it, but I can't sort it by title, date or label. Could you please help. Thanks

My url: http://www.mhd-hdhieu.com/2009/02/table-of-contents.html

Moj svet said...

Hi!
This works great for me. Thank you very much!
Still, I'd like to do some modification: I'd like to rename/translate some things, since I don't use english on my blog.
Namely, I'd like to translate the following: "Blog Table Of Contents", "Displaying all 8 posts", "POST TITLE", "POST DATE", "LABELS". Any idea, how to do that?
Also, is it possible to modify the date format and font size?
Thanks again!
(My blog's TOC: http://moj-zdravi-svet.blogspot.com/2009/02/kazalo.html)

ASI said...

Hi,
I followed all the right steps, at least I think I did, and nothing seems to be showing up in my TOC Post. I was originally going to do this as a post and then switch it to my archive link at the top.
here are the links: thejuicebyasi.blogspot.com
and TOC: http://thejuicebyasi.blogspot.com/2010/03/contents.html

Aneesh said...

@ASI - you haven't followed the steps properly. you have to change http://www.bloggerplugins.org/2005/06/table-of-contents.html to http://thejuicebyasi.blogspot.com/2010/03/contents.html in the codes.
Similarly you have to change http://www.bloggerplugins.org/feeds/posts/default with http://thejuicebyasi.blogspot.com/feeds/posts/default
If you had followed the steps, those codes should have been visible in your page's source. But it is not.

Indra jaya said...

Tanks my friends

Anonymous said...

Hi,

To install this widget using the new blogger **static pages**, is there anything different from the tutorial above?

Thanks a lot.

حسان بن عبد الرزاق said...

I repeat the Anonymous's question above.

Muqeet Soomro said...

Thanks It is working

http://arabiconlinecourse.blogspot.com/2010/02/arabic-online-course-table-of-content.html

komputer-corner said...

thanks for sharing

Greg said...

This works great on my blog, thank you!

Muqeet Soomro said...

I get the custom domain for my blog. Before my custom domain MY TOC working proper. But Now It can not working.I also change the TOC code .blogspot .com to .net PLZ help me

http://www.arabiconlinecourse.net/2010/02/arabic-online-course-table-of-content.html

Harri said...

Hi! I managed to get this thing to work. Only question is how to translate the word "Pages"? I changed the words for "Next" and "Previous", but couldn´t find that "Pages"-word anywhere.

Thanks in advance!

BR,
Harri
http://kotilahelaan.blogspot.com/

J said...

Mine is not working either. My TOC page is http://cash-crate-surveys.blogspot.com/2010/06/archives.html

Why is it just blank?

movie216 said...

Very nice tutorial,I've been looking for something like this. Here's my TOC page http://movie216.blogspot.com/2010/05/movie-archive.html. I changed it to Movie Archive...

Tnx,
Movie216
http://movie216.blogspot.com

Anonymous said...

great post, works good,
but i have a guestion,
can we edit or add something to sort by name (titles) "A to Z" i mean?

ristoni said...

dude, there ain't result
may be u need to make it clearer
tx

Nancy said...

Can this be put in a static page? What changes would I make?

Daniel Crowder said...

is it possible to change the text color? I got it all working, just the Title for the app is almost white with no contrast to the page.

here's my toc http://www.randombrainwork.net/2010/02/table-of-contents.html

Monica said...

I have same question as above, can we put it on a static page?

Aneesh said...

@Nancy,Monica - yea you can put it on a static page. You need to replace the post url with the static page url.

Armetz said...

mine is not working.. i put the TOC link on the top of the page.... when i click on it.. nothing appear....
my toc http://muchikito.blogspot.com/p/table-of-content.html

Nestor Juchnewicz said...

Hi. I would like to know if there is a way to prevent some entries to appear in the TOC, hiding some specific label ???

Thanks for your help

georgina said...

Need a portable script to place it in a seperate page/post listing more than 3000 posts in my blogspot

Any chance you could help me please

all the best

NetBit said...

http://netbit.ubucentrum.net/p/spis-tresci2.html
why TOC is not inside post ?

Vishnu Das said...

thanks..it works...

but what should i do to view that in another page....?

Post a Comment

Please don't spam on here..