Summary: Enable page listings using a "dictionary index" format via fmt=dictindex
Version: 20210426
Status: Working
Discussion: DictIndex-Talk

Questions answered by this recipe

How can I get page listings in a "dictionary index" format, i.e., segregated by initial letter of the page name?


The titledictindex.phpΔ script will enable page listings using a "dictionary index" format. This format can be used by anything that produces a page listing; i.e., one can do things like:

    (:pagelist group=Cookbook fmt=dictindex:)
    (:searchresults group=Cookbook text=index fmt=dictindex:)

For example: the wiki page [[Category.GroupFooter]] can be edited via the wiki and changed so that 'list=normal' can be changed to 'fmt=dictindex' this way every category page will have a dictindex.


Place this file: titledictindex.phpΔ into your cookbooks folder.

Add this line:
to your local/config.php file


To prevent the index links (letters at the top — A, B, C, etc.) from being displayed, set the following in config.php:

 $DictIndexShowLetterLinksByDefault = false;


The letterlinks parameter (may be 1 or 0) overrides $DictIndexShowLetterLinksByDefault, allowing you to control whether the index links are shown or not, for each individual pagelist, like so:

(:pagelist group=PmWiki list=normal fmt=dictindex letterlinks=0 :)


(:pagelist group=Site list=all fmt=dictindex letterlinks=1 :)


Enable page listings using a "dictionary index" format via fmt=dictindex


  • The output can be customized by various $FPLDictIndex...Fmt variables -- see the documentation in the script for details.
  • extdictindex.phpΔ is a modified version of this script so that every index letter has an anchor <a name='$IndexLetter'></a> and that $FPLDictIndexStartFmt contains an index A - B - C - ... where every letter links to the appropriate anchor in the index. Should be useful for a large numer of search results... Nils Knappmeier
    • Just modified it to work also with PmWiki 2.0beta39 Klonk
  • titledictindex.phpΔ is a modified version of this script. It contains the additions made in extdictindex.php but lists not the pagenames, but the pagetitles defined in the separate files. If no pagetitle is defined the pagename will be displayed. I personally think this is the most universal variant. Klonk
    • Modified it to deal better with lowercase titles (also fixed up the whitespaces) Norman Rasmussen
    • Modified with some optimizations as suggested by Pm - Klonk
    • Unfortunately it is not Valid XHTML 1.0 Transitional (W3C Markup Validation Service: http://validator.w3.org/). Seven errors occured.
      • you can change to this
         	SDV($FPLDictIndexStartFmt,"<p id='dictindexheader'>\$IndexLinks</p>\n<dl class='fpldictindex'>\n");
        	SDV($FPLDictIndexLFmt,"<dt><a href='#dictindexheader' id='\$IndexLetterID'>&#9650;</a> \$IndexLetter</dt>\n");
        	SDV($FPLDictIndexIFmt,"<dd><a href='\$PageUrl' title='\$Group : \$Title'>\$Title</a></dd>\n"); 
        	SDV($FPLDictIndexHeaderLink,"\n".'<a href="#$IndexLetterID">$IndexLetter</a>'); 
        - She
    • If you have problems with the above version of titledictindex.phpΔ not displaying the index letters in version 2.2.0-beta44 of the wiki (sorry, not verified for other versions) try replacing line 40 with "$pletter = substr($item['=title'],0,1);" (without the quotes). Daniel Rosendorf - Thanks, included this change - Klonk
    • Incorporated changes provided by She (with a correction for s/$IndexLetterID/IndexLetter/ ). This now validates properly. Said Achmiz August 15, 2017, at 2:14 PM
    • Modified titledictindex.php to allow a string to be inserts at the end of each letter block (in case, e.g., you want to enclose each letter section in a div, etc.). Said Achmiz August 15, 2017, at 4:33 PM
    • Modified titledictindex.php to optionally show, or not show, the list of index links (the letters A, B, C, at the top). Said Achmiz August 21, 2017, at 12:15 AM
  • toggledictindex.phpΔ is modified from titledictindex.php and displays the list by pagetitles but initially hidden, and each section gets toggled in and out of view by clicking on the letter in the list's header. This script uses elements from togglelink.php, but does not need it to run. ~HansB August 01, 2006, at 10:31 AM
  • To remove letters so you just have a horizontal list of pages; titledictindexn.phpΔ is modified from titledictindex.php. To call it use fmt=dictindexn. It is compatible to have both this and the original recipe on at the same time. To be safe, in config.php may want to paste $DictIndexShowLetterLinksByDefaultn = false; --Naturevault

Release Notes

  • 20210426 - update for UTF-8, hide warnings for PHP8. (Petko)

See Also



See discussion at DictIndex-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.