Using Filters
Filters are a way for AZIndex users with some knowledge of PHP programming to tailor the appearance and/or behavior of their indexes. For example, suppose you don’t like the appearance of the alphabetical links at the top of the index, and you can’t get it to look the way you want it to look by using a customized CSS stylesheet. Normally you would be stuck with what you have, but with AZIndex you can use the azindex_alpha_links filter to get in there and tinker with the HTML for the index before it is displayed on the webpage.
Of course, you have to write a function with some PHP code in it to do that, so this is not for every AZIndex user, but if you’re an expert PHP hacker, these are the steps you can follow:
- Find a good place to put your new PHP code. I prefer creating my own little plugin for all my tailoring needs, since there is no chance of it being overwritten when upgrading, but you could add it to somewhere like functions.php inside your theme directory.
- Add the following line to your code (not inside any function):
add_filter('azindex_alpha_links', 'my_alpha_links_filter'); - Just below that, add a new function called my_alpha_links_filter.
function my_alpha_links_filter($output) { /* My HTML modification code here */ return $output; }Now all you have to do is write the code to modify the HTML in $output to make the alpha-links look the way you want them to look. (Well, yes, that’s the hard part, but you get the idea!)
If you would rather throw away the generated HTML and start again, you can add extra parameters to the filter function which will contain all you need to build set of alphabetical links in the style of your choosing:
- First you have to modify the add_filter function call:
add_filter('azindex_alpha_links', 'my_alpha_links_filter', 10, 5);where 10 is the default priority of the filter (we don’t use it, but it has to be present in the call) and 5 is the number of parameters AZIndex will pass to your filter function.
- You also have to modify the filter function to access the extra variables being passed to you:
function my_item_filter($output, $idindex, $links, $pagelink, $currentpage) { /* My HTML modifying code here */ return $output; }where $idindex is the id of the index being displayed (in case you just want to modify one index out of many), $links is an array of the characters in the links and the page in the index they link to, and so on.
Note: If you only need to know the id of the index, then you can set the number of parameters to 2 in the add_filters call.
Now that you know everything there is to know about using filters (well, not really, but it’s enough!), you can look up the details of each AZIndex filter in the following reference pages.
lovewp said:
Hi everybody,
I agree with all of you: this is a very Great Plugin! Thanks to Mike .
Now I need your help (Mike or anybody who could) .
1- I create an author index on my site . It seem working very well . But how I can group items with the same heading under one main entry without selecting subheadings ? I mean each author name appear only once and when we click on it we’ll see all his post. Please take a look on my page
2- I have another site (same server, same hosting) but the author index page on this site can’t be read (please click on this link for reading the error message)
Many thanks in advance
LW
lovewp said:
2- I have another site (same server, same hosting) but the author index page on this site can’t be read (please click on this link for reading the error message)
Sorry ! I don’t know why the above link is not working .
Julie said:
GREAT plugin, thank you!!
@curtis klope, thanks so much for the tweak, i was experiencing the same issue and was so not looking forward to diving into the code, so was thrilled to find a quick solution!
i think it is a bug and your fix should be rolled into the next release…