Beyond the 100 posts limit

After a lot of trial and error, and without having any success to develop a decent piece of programming to call JSON-feeds recursively, I suddenly had a flash of insight in how we can cross the 100 posts limit of the Table of Contents Widget. It's all because of Annie, one of those friends in the Blogosphere that makes me (and others) think. She has 101 blog posts, and is in dire need of a Table of Contents that can list all 101 of them. Well, check out my sidebar, the link will show Annie's table of contents, with all 101 of them!

The new BlogToc Widget release is updated in several ways:
- it now supports > 100 posts
- the link is more user-friendly
- a note is added displaying number of posts and filter applied

If you have more than 100 posts, you have to duplicate the JSON-script-call that is in your sidebar several times, each time with a different start-index. If you have more than 100 posts, you need 2 calls like this:

<script src="http://YOURBLOG.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=1&max-results=100&callback=loadtoc"></script>
<script src="http://YOURBLOG.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=101&max-results=100&callback=loadtoc"></script>

If you go beyond 200, you will have to add another line, starting at start-index=201 and so on.
It is as simple as that. Took me DAAAAAAAAAAAYYYYYYYYYYS to come up with it.

There is a new class added, .toc-note, that you can use to style the top-line. I used a simple styling, a 5px left-padding and a 80% font size.

Next stop: adding customization options (especially language).

This is what people say:

john c abell said...

Oh my, Hans, you have been busy!

Have you already changed "TOC" to "Table of Contents?"

Many Thanks!

Junio said...

Good! My 146 posts are ALL displayed, je... :) (THANKS)

rudi said...

Hi Hans

Great job - thanks!

When the Table of Contents is NOT displayed, I have a large-ish empty space at the top of the middle column (i.e. the HTML-page element seems to push down all the posts below it). I noticed the same effect (only less severe) on your blog. Can this be neutralised?

rudi said...

Hans

Further to my comment above, could the Table of Contents be made to appear on a separate page, rather than above other published posts?

This would be an altogether 'cleaner' solution, and would presumably solve the 'space' problem as well.

Claudya said...

Uau! Great job!!! Congratulations Hans...

annie said...

Thanks, once again, Hans! The hack is wonderful. I believe it is displaying all of my posts, even though the little title says...displaying all 100 posts. On your blog, with my new post added, it says...displaying all 102 posts.

So, I will try and figure that one out, plus how to get rid of the dotted line above my first post on the main page. Little problems in the scheme of things!

I barely had time to put it in my template. My house has sold, and I'm getting ready for the big move. Packing...ugh. Moving...double ugh. Just ugh in general. But, in a couple of months, I will be settled in and hopefully back to business as usual!

Thanks again for the wonderful TOC.

john c abell said...

Is there a way to change the default TOC display to "Post Date" (latest first) rather than "Post Title" (a-z)?

Mina said...

Hi Hans,

I know this is off the subject, but I need some help and you seem to know alot about Blogger "Beta".

In old Blogger, I used the MainOrArchivePage tag alot! It helped keep the post pages uncluttered. However, I just tried to use the tag with the "Beta" and they're not recognized or honored. I put them around the "b:section" that I don't want to appear on the post pages. I save the template and publish the blog, and the section still shows on the post pages.

I'm just wondering if you know anything about this and can help me out.

Thanks,
Mina

magic said...

Hans, terrific hack, my gratitude knows no bounds. How can I get rid of the date and label columns? I just want to list the post titles.
Cheers, and thanks again.
M

Anonymous said...

Hi,
Great Hack! But I noticed the Page Source does not show any of these links. Which means the Search Engines do not pick them.
Comments?

Arti Honrao said...

Awesome! Very useful! Something, which I was looking for since a long time without knowing that it was right under my nose :)

If you see my blog under credits you will know what I mean :D
To make it easy ...
I have used a few scripts of yours but had missed ToC!


GBU
Arti
Straight From The Heart

Jon said...

Your table of contents is amazing :) My blog has many labels and I was wondering if it were possible to cut off the label list after X labels or completely remove the labels so as to only show the title and date?

Thanks,

Jon

KONFUZiUS said...

Hi.

I tried that widget out. I works perfectly, BUT I have more than 1000 post and if I tried to show all of'em with that 100+ hack (http://beautifulbeta.blogspot.com/2007/04/blogtoc-widget-released.html) I've waited more that 2 min. (200 and 300 shows good, but not 1000).

-> Too much time for loading (slow down process rapidly), that's why I deleted this hack.

If you have some suggetions for stable and fast work (+1000), please answer.

Thanks.

(<div id="toclink"><a href="javascript:showToc();">Show TOC</a><br/><br/></div>
<script style="text/javascript" src="http://home.planet.nl/~hansoosting/downloads/blogtoc.js"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=1&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=101&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=201&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=301&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=401&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=501&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=601&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=701&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=801&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=901&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=1001&max-results=100&callback=loadtoc"></script>
<script src="http://sla-va.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=1101&max-results=100&callback=loadtoc"></script>)

Arti Honrao said...

Hi Again!

As my previous comment here shows I really WANTED this feature. I had been looking for it since a long time but now when I have it I am having troubles with it. :(
A few visitor friends complained that they had problem of loading with the ToC. Personally, I found that the blog was slow to load when I had Table of Content and after removing it the blog loaded faster.

Now ...
A simple request, please, pretty please ...

Is there any way to make the ToC load faster? I want the blog to load faster but I want this feature as well.

Awaiting a reply
[You can use the contact me form at my blog]


GBU
Arti
Straight From The Heart

mistery said...

ignore my previous comment. the problem was on my side. recent posts widget is working fine. my apologies.

Jos said...

Many thanks for this. Works like a treat!

Best Blogger Widgets said...

Thanks for the very useful hack!

Anonymous said...

is there a way to get this to work for Blogger Classic?