User:Robbiemuffin/Templates/Contents Block/doc/HowTO

From Wikibooks, open books for an open world
Jump to navigation Jump to search


HowTO Automatically Generate Contents


First, let's have an example:


Cute little bit of CSS right? But that's not the cool part, the cool part is, it is generated automagically from User:Robbiemuffin/Templates/Contents Block/doc/SampleContents. So, you just have to maintain the inner list data, in a nice clean page, to generate your contents. If you only ever have one contents list, maybe that's not so important. But if you want to keep one on each Chapter, a nice small one like the above (which will expand quite a bit, by the way), you can do that too.

Now, if you generate the list pages from category tags, you're set, right? Because then you can just add a quick category tag to any new page in the book, and the contents update automatically. That's spiffy. So... how do you do that?


First thing's first. Let's make a category for our book. Add a category tag (something like [[Category:Robbiemuffin book contents]]) to one of your pages. This way, when the page is refreshed, you'll have a category all made up for you. Sometimes that takes a minute though, so you might want to pour some wine.

this page was brought to you by an Ajax hacker