[pmwiki-users] How to list the categories a page belongs to? (fwd)

Peter & Melodye Bowers pbowers at pobox.com
Thu Feb 28 14:09:49 CST 2008


I believe that Hans has put together a form of pagelist which works from
within an MX instead of a standard MX.  Using that format and combining it
with some of the tools in WikiSh will result in something pretty close to
what you're looking for.  It will look something like this:

{(sed 's/^[^\[]*(\[\[![^\]]*\]\]).*$/\\1/' - (grep --line_prefix:'*
PAGETITLE: ' '\[\[!.*\]\]' (pagelist link=Category.{$Name}
fmt=simpletext)))}

That solution assumes that you will only ever have a single category on a
single line in the source.  The regex would have to get a little more
complicated to allow more than one category on a line.  Given that
assumption, this brings us to this point:

* Gone with the wind: [[!Movies]]
* Gone with the wind: [[!Drama]]
* Blues Brothers: [[!Movies]]
* Blues Brothers: [[!Musical]]
* Red planet: [[!Movies]]
* Red planet: [[!Science Fiction]

I don't know if that is close enough for you or not.  

The {(catlist)} that Hans pointed out has potential to do exactly what you
want with a little modification.  Basically you just need to get it to read
the {(pagelist ...)} output to get the list of pages and then prefix the
list of categories with the title and format everything nicely...  

-Peter

PS The code above is untested.  If you're actually going to use it I can
copy it onto a page and get it a little more exact for you...




More information about the pmwiki-users mailing list