Table of Contents - another method
In this post, A del.icio.us way to make a previous post list, I explained how to add a Table of Contents to your blog. The method used del.icio.us as it's backbone. And it works well, especially for those that haven't switched to Blogger Beta. Well, I have switched, and it doesn't work quiet as seamlessly as before. I have to go through a few more steps.
Hans, from Beautiful Beta, has figured out a different, more streamlined, method of making a Table of Contents. I'm going to detail it here, because unless you are very familiar with beta, you may be lost.
First open your dashboard and go to Template/Edit HTML. Check the box to 'Expand Widget Templates'. Scroll down until you find:
<b:includable id='main' var='top'>Replace with:
<!-- posts -->
<div class='blog-posts'>
<b:loop values='data:posts' var='post'>
<b:if cond='data:post.dateHeader'>
<h2 class='date-header'><data:post.dateHeader/></h2>
</b:if>
<b:include data='post' name='post'/>
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:post.allowComments'>
<b:include data='post' name='comments'/>
</b:if>
</b:if>
</b:loop>
</div>
<!-- navigation -->
<b:include name='nextprev'/>
<!-- feed links -->
<b:include name='feedLinks'/>
</b:includable>
<b:includable id='main' var='top'>That is the first part of the process. The second part involves putting a link in your sidebar. In Blogger Beta, open Dashboard/Template/Page Elements, then open 'Add a Page Element'. Select the 'Link List' widget. Give your widget a title in the top box, and name your link in the bottom box. (Something like Content, or Post List.) In the 'New Site URL' add this link:
<!-- posts -->
<div class='blog-posts'>
<!-- on a label page, add a header saying 'Contents' -->
<b:if cond='data:blog.homepageUrl != data:blog.url'>
<b:if cond='data:blog.pageType != "item"'>
<b:if cond='data:blog.pageType != "archive"'>
<h2 class='date-header'>Contents</h2>
</b:if>
</b:if>
</b:if>
<!-- Start loop for displaying posts here -->
<b:loop values='data:posts' var='post'>
<!-- Date-headers are only displayed if on main, item or archive page -->
<!-- If on label-page, then no date-header -->
<b:if cond='data:blog.homepageUrl == data:blog.url'>
<b:if cond='data:post.dateHeader'>
<h2 class='date-header'><data:post.dateHeader/></h2>
</b:if>
<b:else/>
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:post.dateHeader'>
<h2 class='date-header'><data:post.dateHeader/></h2>
</b:if>
<b:else/>
<b:if cond='data:blog.pageType == "archive"'>
<b:if cond='data:post.dateHeader'>
<h2 class='date-header'><data:post.dateHeader/></h2>
</b:if>
</b:if>
</b:if>
</b:if>
<!-- Here we start displaying the posts. -->
<!-- If we are on a label page, only the posttitle is displayed -->
<!-- On other pages the entire post is displayed -->
<b:if cond='data:blog.homepageUrl != data:blog.url'>
<b:if cond='data:blog.pageType != "item"'>
<b:if cond='data:blog.pageType != "archive"'>
<a expr:href='data:post.url'><data:post.title/></a><br/>
<b:else/>
<b:include data='post' name='post'/>
</b:if>
<b:else/>
<b:include data='post' name='post'/>
</b:if>
<b:else/>
<b:include data='post' name='post'/>
</b:if>
<!-- If on item page display comments -->
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:post.allowComments'>
<b:include data='post' name='comments'/>
</b:if>
</b:if>
</b:loop>
</div>
<!-- navigation -->
<b:include name='nextprev'/>
<!-- feed links -->
<b:include name='feedLinks'/>
</b:includable>
http://yourblogURL/search/label/?max-results=999Make sure you replace yourblogURL with your URL. And that is it. All except for visiting Hans and thanking him for such a wonderful hack!!
46 Comments:
Dude,the first link is a dead link, could you kindly fix it? Thanks
w.y. thanks for letting me know. I fixed the broken link.
Nice to see an artsy-fartsy picture of you on the internets!
peace & love
karmacharmer
@completely anonymous...so good of you to notice! I was striving for more of the artsy and less of the fartsy!
BTW, congrats to you and the Bobert!!
Hi, Annie
Interesting idea!
But after I tried to apply this hack, it changed all webpage post articles to the form "Table of Contents lists" when I clicked "Older Posts" link at front-page bottom. In your blog, the hyper-link is "http://bloggeruniversity.blogspot.com/search?updated-max=2006-10-03T17%3A42%3A00-05%3A00&max-results=5" for now.
I want to know if your page posts have the similar situation. yes, when clicking the "older post" at page bottom (http://bloggeruniversity.blogspot.com), your posts "sometimes" will be changed into the list form but sometimes it doesn't change, keeping title and text. strange? Han's beautiful bata, however, doesn't have this problem.
As to lebels, it works very well :)
@Woody, I will have to play with this one and see what happens!
Any idea as for how to make it into a drop-down menu?
@troubled, that is a great idea! I will have to think on it & play with it awhile. If I come up with a way I will write a post about it.
Hi Annie,
The Hack Goddess! (After calling Hackosphere's Ramani the Hack God! You can tell I am new to this and just soooo excited huh?)
Well, I really want what you are offering here but I have used Ramani's Peekaboo Posts hack and notice that some of my code is a bit different to the bits you have highlightd to replace.
Would it be too much to ask for this great hack to work with Ramani's hack?
Thanks for your time!
SJ xx
http://skankyjane.blogspot.com/
@jane, Ramani truly is the hack god. Much much better then I am. Since you are trying to incorporate his hack with this one, I would ask him how to modify it. If he doesn't respond, I will try...but it seems beyond my scope.
Let me know one way or another!
Ok, sure thing, thanks Annie,
SJ xx
Hi Annie,
The Table of Contents link seems to be dead.
Guess what? When I spend time on here, reading your instructions, I actually understand them. I'm either getting a bit more clever or you've got a ...for dummies, going on here. :P
@terence, It must of been one of those gliches I can never understand because the link is working now.
And, it is no mystery that you are understanding my site. The more you read, the more you understand. Plus, I try to write my posts so 'non-techie' types can understand them. I'm sort of a 'go-between' for the hard-core hackers and the normal day to day computer users.
Yeah, that's why I decided on 'seems to be dead' coz my browser seems to want to go there, but won't. I've favourited the guy's site, so I'll see what T of C's are ,eventually.
Hi Annie: Very cool hack! I was wondering if you could help me understand where the hyperlinks for Newer Posts and Home are being generated. I'd like to at least be able to apply some formatting to them - on my test blog, they appear much to close together and immediately after the list.
hi annie!
firstly, i'd like to say i'm an avid fun of your hacks, and like the rest of your non-techie fan club, i wanna thank you for making your hacks and tweaks (i don't even know the difference:) quite easy to understand. my blog is 50% annie's genius!
secondly (this is where i'm gonna get thick), is there any way that singpolyma's calendar navigation can work with your table of contents method coz i'm using this hack of yours too. see, his utilizes the feed identical with the one you're using here. so when i use it for the calendar, i dunno why it becomes either invalid or the 30 boxes team says they can't get the data or stuff like that.
thirdly, like jane i'm using ramani's 3-column minima template too, so thanks again for your hacks being easy to implement with it!!(this has nothing to do with "secondly" promise!(",))
and btw, i know you're not really into dark templates, uhm, mine is...so i'll work with purple moggy's theme switching hack soon. i just wish i was as gifted as you are haha!
god speed!(",)
@vï†Ã¦, I am a simple coder...meaning if it gets terribly involved, I'm lost too. I don't understand enough to know why the two hacks conflict. Perhaps if you ask Stephen at Singpolyma he could give you an answer. He is a great hacker!
@robert, I didn't forget you...I just had to find some time to find your answer. Find this in your template:
#blog-pager-newer-link {
float: left;
}
#blog-pager-older-link {
float: right;
}
#blog-pager {
text-align: center;
}
That is where you can format 'Newer Posts/Home/Older Posts'.
Hi: I want to thank you about this "hack" because it let me to make my little blog (gerardoblanco.blogspot.com)more..."browseable", i mean that i have several post in some labels, and with this ToC is very much simple to show them. I've change a little bit the code so i can do the same with all the archive links, just delete a couple of lines.
I guess that i'll need to know more about CSS, to make that show as i want...
I have a little question about show/hide de dateHeader:
If a do want to show the date on labels pages (as i do on archive), should i have to delete all the if?
I mean the if after the loop, because i think that there you ask, if is the main, or if is an item or if is archive, then you show date, else, you don't. So if i want to show date on all (labels included), i should delete all of that? or should i put a code that if data blog pageType == all, then show the date?
Hi annie,
Thanks a lot. I applied this in my blog and it worked. Is there something I can do to put a margin in the titles? Thanks :-)
igorotblogger.blogspot.com
@bill, I think this will work. Find this code in your CSS style sheet:
.main .Blog {
margin: 0;
}
Change it to this:
.main .Blog {
margin: 10;
}
That should give you a margin!
Hi Annie,
It Worked! Thanks so much you are very helpful :-)
Blessings,
Bill
Hi Annie,
Its me again tapping on your expertise. Hope you won't get tired helping clueless bloggers like myself :-).
I noticed when I placed this hack in my blog that, now, only the titles of the posts contained in the categories/labels are displayed when you click these categories. Is there a way by which I can keep the table of contents (coz its really neat) and yet have the blog entries displayed in full when I click the categories/labels. Thanks again and more power :-)
Bill
igorotblogger.blogspot.com
@bill bilig, I never noticed that before, but then it always displayed as I wanted. For example, when someone clicks on a label, all I wanted to show was the list of titles. So, I don't know if there is a way to force it to show all of the posts. I'll have to check into it.
Hi Annie,
Thanks. More power :-)
Bill
@Gerardo Blanco, that is something I'm not sure about. I would open a test blog and experiment with it. I'm sorry that I don't have more time to test it myself.
Hi, annie, many thanks, I applied your posting about Table of Contents-Another Method, it worked well. But, I could not find yet the way to hide/show the TOC toggle in my sidebar, have a suggestion?
Is there a way to have a post snippet appear on the label pages and archive pages instead of just the post title?
hi there...i'm really having a problem here...i wonder if you could help me regarding the Table of Contents...because I have a classic blogger template and i'm not sure whether i could use it in my blog...pls help...i really would like to put the ToC in my blog...thanks a lot... :-)
I think it has to be Blogger Beta. It works with widgets and Classic Blogger does not use widgets. I, personally, don't know that much about coding to make a widget work with Classic Blogger. Not to say it can't happen, just that I don't know how to do it.
It works great! THANKS!!!!!
Will this list my blogs by title and do away with the dates? I don't want my readers to have to click thru that hierarchy to get to the titles, i want the titles only in the list. How do i do that?
thanks for any help.
Jae
http://usedbythemuse.blogspot.com
@jae baeli, Hans has detailed instructions on this widget... BlogToC Widget Released and Beyond the 100 posts limit.
Annie,
would you know how I could make the links or search results to stand out more? Maybe I could change the background.
thanks!
Annie, when you search my blog, it only displays the first 20 results for some reason. How do I make it display 100 or so results or unlimited? (And as you can see I allow 15 posts on my homepage)
@John Smith, in the post is a link to Hans blog and he explains how to show unlimited.
Annie (and John Smith), I followed the first part, but in the second part, instead of just using a link, you can make an image that will direct you to that same link. I could probably have made a nicer one on my blog (it's on the right. It's a small version of the header, but it also has 'previous posts' written on it), but anything is better than having a big archive section. I'm a work in progress.
And thanks. Again.
I installed the widget on my page but i'm having a problem: my TOC, unlike yours, differs the upper case from the lower case when i select to display alphabeticaly. Did you modified the script or have any solution to my problem? Thanks
This is Great but how can we sort it alphabetically?!
Please,please please,How can i make the links to post show alphabetically?..i've been up 24 hrs looking for a solution...please,please
@Anonymous, you are making me laugh! I don't know the answer, but I'm putting it on my todo list.
Always wanted to create one like this! Thanks for it! Love BlogU!
Nice tips Annie,.....
I like your TOC
Jenni:
Hi Annie I am having PR problem with my blog Telekomni.I ve been using Social Media like Facebook,Digg,Twitter and Stumble upon to get high PR but its still '0'..?