I have had a couple of questions about putting an index in the sidebar of a blog so that it is visible on every page. After a bit of testing and fiddling, it turns out that, yes indeed it is possible, and it’s actually quite easy to do. The trick is to use a sidebar widget, and here are the step-by-step instructions on how to do it:
Log in to your blog and go to Design >> Theme Editor.
In the Theme Files list on the right you should see an entry called something like “Theme Functions (functions.php).” Click on the link and the file will be loaded into the editor window.
Now we have to add the following line at the top of the file to enable WordPress shortcodes in sidebar widgets:
add_filter('widget_text', 'do_shortcode');
IMPORTANT: It must be inside a PHP tag: i.e. somewhere between <?php and ?>
For example, if there is a line containing <?php at the top of the file, then add it on the following line. (Just make sure you don’t put it inside a PHP function). If the file is empty, or doesn’t have those tags, you will have to add them yourself:
Click Update File at the bottom of the page to save your changes.
Now go to Design >> Widgets and add a Text Widget to your sidebar.
All you have to add to the content of the text widget is the AZIndex shortcode for your index. For example, if your AZindex index has an id of 2 (check the AZIndex admin page for the id), add the shortcode:
[az-index id="2"]
Save your changes and go take a look at your new sidebar.
These instructions assume that you are already using a theme with a widget-enabled sidebar. If you do not see the new text widget, then it’s possible you will need to “widgetize” your theme (search for that term on Google for more information). Most popular themes are already widgetized these days.
I have tried this, and it works fine, though obviously there isn’t much room for large entries in your index. There is one site I know that is using this trick to display an index of movies in their sidebar. If you try this yourself and have any questions, just leave me a comment.
A leopard feeding on an what’s left of an unlucky impala
This was one of the highlights for our stay in the Kruger. We sat and watched for about 30 minutes as the leopard tucked into a meal of very rare impala steak. Not only that, but there was a hyena sniffing around below the tree waiting, in vain, for something to drop from above. And I’ll tell you something, those hyenas are huge! People tend to think that a hyena would be no match for a leopard, but in truth it’s quite the opposite. If the leopard had been on the ground with that kill, it would have easily been driven off by the lone hyena I snapped at the foot of the tree.
Apologies to everyone who has been waiting for answers to their questions. No excuses — just action to make up for lost time. I will be going back though all the comments and catching up as quickly as I can.
I will also be posting select photos from my summer vacation to South Africa. It’s a beautiful country and the people we met, of all races, were nothing but kind and generous. They are still struggling with the after effects of decades of segregation and injustice, and I can only hope their leaders act wisely and bring peace and prosperity to their country.
My apologies for not attending to the questions, suggestions, and comments left on my blog in the past three weeks or so, but there was a very good reason for my absence… I was having way too much fun on vacation in South Africa and Mauritius with my sister and her wonderful family. The highlight of the trip was undoubtedly our stay at the Ngala Private Game Reserve on the border of the Kruger National Park where we were treated like royalty and given the experience of our lives on safari in the African bush.
As a taster of what we saw, here are photos of the legendary “big five”.
First, a female leopard and her cub. This amazing photo was snapped (I think) by my sister, so I can take no credit for the captured moment.
Unfortunately lions were a little scarce in the game park while we were there, but we managed to intercept a couple of male lions before they vanished into the Kruger in pursuit of their pride.
Bull elephants we saw plenty of… this one in particular, and thereby hangs a tale (but it will have to wait for another day of two).
We caught up with a rhino family just as the sun was setting over the park.
And finally, we only caught a glimpse of the water buffalo which, thanks to megazooms and megapixels, seems a lot closer than it actually was.
Plenty more photos where those came from, but I promise not to post all 2,000 of them!
Nice timing! Just as I am about to go on vacation and don’t have much time (and only a very slow computer) they go and release a major new version of WordPress! Ah well, I have managed to perform a quick test with both of my plugins on the new version and I am happy to say that:
AZIndex seems to be working fine, and
TinyMCE Entities Patch is obsolete
Yes, it’s actually good news that my TinyMCE Entities Patch plugin is no longer necessary — WordPress has fixed the bug my plugin was designed to fix. I may get the chance to update the plugin tomorrow so that those who installed it so they could keep the spaces around will still be able to use it, but I can’t promise anything at this point.
UPDATE: Well, I spoke too soon yesterday — there was a problem that many other plugins also seem to have stumbled over thanks to a change in the get_option WordPress function (naughty WordPress!). I have updated AZIndex to v0.5.4 with a workaround for the problem on WP 2.6. The plugin should continue to work with WP 2.5 and WP 2.5.1, and with WP 2.6 even if they revert the behaviour of get_option back to the way it was in 2.5.1.
AZIndex version 0.5.3 has just be released. It’s just another interim version as I am gearing up for my summer vacation, mainly to fix a bug where the sorting of the headings was case-sensitive. I’m not sure how that one escaped detection for so long!
I also took the opportunity to add a filter to the plugin — ‘azindex_heading’ — which, if set, will be called for every heading before the index is sorted. This allows users to write a filter function that can modify the heading in ways that can’t currently be done using the AZIndex plugin — for example, if you want to strip words like “A”, “An” and “The” from the front of the heading then you can write a simple filter to do that.
Below is an example of such a filter. It will remove “The”, “An” and “A” (of various cases) and put them at the end of the heading instead — e.g. “The Great Escape” will be transformed to “Great Escape, The”. Useful for certain types of indexing:
Note that this is just an example and there may be a more correct way to do the same thing, but it works as advertised. You can add your filter function to the functions.php file in your current theme. Remember to clear the index cache (from the AZIndexes admin page) once you’ve added the filter so that the altered headings will be sorted in the correct order.
If anyone comes up with a useful filter function of their own, please feel free to post it here.
Have you ever slaved over the formatting of particularly tricky blog post then forgotten how you did it? Ever gone back and edited an old post to hunt down the fiddly HTML you wrote so you can use it again in a new post? Well, I have, and I just found out something that makes the whole process easier and quicker.
Are you thinking of using a plugin that uses shortcodes? (Shortcodes are tags in square brackets like [az-index id="1"] that some plugins use to embed content into posts and pages.) Do you want to be able to use a shortcode in your blog’s sidebar instead of your post or page?
Well, if the answer to both those questions is “Yes” then you have come to the right place!
I have just added the beginnings of an AZIndex User Guide to the blog. The first installment is mostly a “Getting Started” guide for those who are just starting to use the plugin, but I hope to add full documentation for the plugin and all its many settings by the time it’s complete. Unfortunately, since there are a lot of things to talk about with AZIndex, that is going to take some time — probably a few months — but I will continue to add new sections as I write them.
Feel free to comment on the AZIndex User Guide if you spot a mistake or if you find it too confusing in places.
High time for another Friday funny — this time my all-time favorite Doctor Who sketch, The Web of Caves. I never tire of watching this one. Anyone who remembers watching the old Jon Pertwee or Tom Baker episodes will appreciate all the little observations they put into the sketch, especially the way they pronounce the word “Dok-tor” in such mock menacing tones. (Yes, the enemies of the Doctor really did say it that way in those days!).
You may not recognise him under all that makeup, but the Doctor’s main protagonist in the sketch is David Walliams, later of Little Britain fame (and fortune).