Under African Skies

Under African Skies
Sunset over the Kruger

The weather, while we were at the Ngala Game Reserve, was cool and dry but overcast most of the time.  That made for some flat light when taking photos of the wildlife which certainly wasn’t ideal.  But on all three evening drives, the clouds would break up enough to give us some beautiful sunsets.  Sadly, most of my attempts at capturing them on camera were not that great, but this is one of the better ones.

Eureka! Indexes in Chronological Order

AZIndex LogoAsk and ye shall receive!

I have been going through the backlog of comments and noted that a couple of people wanted to sort their indexes in chronological order — i.e. they want the list of posts sorted by date with the most recent at the top.  So I was just pondering the issue, wondering if I should really add this feature even though it’s not really something AZIndex is designed to do, when I suddenly had “D’oh” moment…

You can already do this with the current release of AZIndex!  (By using a one-line custom compare function.)

Here’s how you do it:

Continue reading

Wildcatting, African Style

African Wild Cat
Sneaking a Peek at an African Wild Cat

For all you feline fanciers out there, thanks to the new 10x zoom camera I brought for the trip, I was able to snap a photo of an African wild cat as we were being driven from the airport into the game park.  Appartently they are quite rare, even though we saw another one a couple of days later.  Not as impressive as the big cats they share the African bush with but still, they do take a good photo, don’t they?

Adding An Index to your Blog’s Sidebar

AZIndex LogoI 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:

  1. Log in to your blog and go to Design >> Theme Editor.
  2. 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.
  3. 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:

    <?php
    add_filter('widget_text', 'do_shortcode');
    ?>
  4. Click Update File at the bottom of the page to save your changes.
  5. Now go to Design >> Widgets and add a Text Widget to your sidebar.
  6. 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″ escape=”true”]
  7. 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.

Beauty and the Beast Combined

Beauty and the Beast Combined
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.

The Hopeful Hyena
The Hopeful Hyena

I Have Returned…. Again

Who says I never get up early?
Sunrise over the Kruger National Park

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.

Where the Wild Things Are

The wanderer returns! 

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.

Leopards at Ngala

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.

Lion

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).

Elephant

We caught up with a rhino family just as the sun was setting over the park.

Rhino

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.

Water Buffalo

Plenty more photos where those came from, but I promise not to post all 2,000 of them!

WordPress 2.6 Released

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:

  1. AZIndex seems to be working fine, and
  2. 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 0.5.3 Released

AZIndex LogoAZIndex 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:

add_filter('azindex_heading', 'my_filter_heading');                  

function my_filter_heading($heading) {
   if (preg_match('/
^(THE |The |the |AN |An |an |A |a )/', $heading)) {
       $split = explode(' ', $heading, 2);
       $heading = $split[1].
', '.$split[0];
   }
   return $heading;
}

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.

WordPress Quick Tips #4:Formatting Your Posts the Easy Way

blogger

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.

Continue reading