Category Archives: AZIndex

AZIndex : The Lowdown on Caching Index Pages

AZIndex LogoSince the latest release of AZIndex (0.6) incorporates full support of the widely used WP Super Cache plugin, I thought it would be a good idea to explain how caching works with the AZIndex plugin.  For most of you, especially if your WordPress blog doesn’t use a caching plugin like WP Super Cache, it may be too much information, but for those who want to get the best performance out of their blog’s index pages, read on.

Continue reading

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

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.

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.

AZIndex User Guide Under Way

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

Announcing AZIndex version 0.5.1 (lean, mean caching machine)

AZIndex LogoPhew!! The latest and greatest version of AZIndex is now available.  As I mentioned in a previous post, the main enhancement this time is caching.  Large indexes will load much, much faster in this version when they are being cached.  Adding or modifying posts will cause AZIndex to check to see if the index has been changed as a result, but it will only invalidate the cache if a post should be added to, deleted from, or must change position in the index.  Kind of cool, really.

Anyway there was a little hiccup getting 0.5 out into the WordPress repository, which might have caused one of two people to download a bad version.  But I’ve sorted out the problem, so it’s safe to upgrade to 0.5.1 when you’re ready.

(Update: Changed to version 0.5.1 after I fixed a minor bug — that produced a scary but inconsequential error message when creating a new index.)

AZIndex: Caching In — Update

AZIndex LogoJust a quick update for those who are following developments for my AZIndex plugin (is there anybody out there… there… there… ?).

Anyway, it looks like I have a viable caching solution almost completed, and the speed improvements are quite gratifying.  I have created several test indexes containing over 1100 items and the index pages load anywhere from 4x to 50x faster when they are being cached, depending on the options set for the index.

Obviously indexes with multiple pages see the biggest gains because if you put 1000 items on one index page, the plugin still has to loaded all 1000 items from the database even though they don’t have to be sorted.  Even so, a 4x speed improvement is nothing to sniff at.  But if you have a large number of items in the index, it’s only natural to have them spread over multiple pages, so in most cases you will see at least a 10x improvement over a non-cached index.

I have added an option to disable caching, but I recommend against using it unless you think you might be having problems with caching, and you can reset the cache from the admin page if necessary.

How does AZIndex know when the cache is out of date?  Well, it attaches to the WordPress action hooks which fire when someone saves or publishes a post.  Each index maintains a dirty list of posts and pages that have changed since the cache was last rebuilt, and when the index is next display, it checks though its dirty laundry (if you will) to see if the ordering of the items has been affected by the changes, or if a post needs to be removed from or added to the index.  If it does find the index needs to be updated, then it will rebuild the cache causing a one-time slower load for one very slightly unlucky user.

Hooking changes to custom fields turned out to be a pain, since there are no definitive hooks for them, and you can change them without having to save the post afterwards.  In the end I attach to the Ajax hooks which fire when a user is editing a custom field.  That will probably work for 99% of all custom field changes, but if a blog uses another plugin to change custom fields using the function calls, then there is little AZIndex can do to detected those changes.  But in the worst case, all the blogger has to do is manually clear the cache once all the changes have been made.

So, be on the lookout for AZIndex v0.5 with full caching support sometime this week, just in time for the holiday weekend.

New Version of AZIndex Plugin in the Offing

AZIndex LogoI will be updating the AZIndex plugin to version 0.4 within a couple of days after I have done a bit more testing.  It contains just about all the new features I plan to add (except for caching) before I declare the beta phase over.  The new features include:

  • An option to use CSS style striping to decorate your index entries (e.g. add a gray background to alternate entries).
  • An option to use your own customized sort to sort an index.
  • An option to customize which alphabetical links appear with your index.
  • An option to place index entries that do not begin with a character or number at the end of the index instead of the beginning.
  • An option to ignore punctuation like quotes or double-quotes while sorting the index (useful if some of your post titles are in quotation marks, for example.
  • Safe upgrades to new versions without having to uninstall and recreate your indexes.

I think that’s more than enough functionality for the first major release of this plugin.  Thanks to everyone who has given me feedback, reported bugs, or suggested enhancements.  This plugin is already much the better for your help, even though it’s not quite finished yet.

I hope to have the caching done before I go on my summer vacation, but it could be tricky to do, so I can’t promise anything.  However, from playing with the plugin myself, and from feedback I have received from a couple of users, if you are holding off installing AZIndex because of my dire warnings about performance, it seems that I might have been a little too cautious.  If your index contains fewer than, say, a couple of hundred entries, and is not going to be accessed by thousands of users an hour, then I think you’ll find that it’s ok to install without the caching.

So keep your eyes peeled for an update to AZIndex.  It should be coming your way before the weekend is over.

AZIndex Demos offline for a while

Apologies to anyone coming here to look at the AZIndex demos.  I seemed to have done something aggravating to those pages so I have taken them offline for a while.

As they say…  “Normal service will be resumed shortly.”

UPDATE: And, as promised, the demos are back.  User error was to blame (as usual) and not my wonderful plugin  😆

Announcing AZIndex Plugin for WordPress

Announcing the AZIndex Plugin, a flexible WordPress plugin for generating alphabetical indexes of your weblog’s posts.

Enhance your WordPress blog by creating multiple, three-level alphabetical indexes of your posts based on any combination of post title, author, extract, or custom fields of your choice. Select which posts are included in your indexes using a combination of categories and tags, display them in up to four columns on a single page or over multiple pages.

Visit the AZIndex Plugin page for more information and downloads.