> Is there a way to get a list of which categories a partuclar page belongs to?
you can try markup erxpression {(catlist)}
http://www.pmwiki.org/wiki/Cookbook/MarkupExpressionSamples
Note that the page will be opened, as the expression has to look
through the page to find category links.
The default output is a csv list.
Another way for showinfg actual cat links may be to put your cat
links always into an anchored section, and then include that page
section in your pagelist listing (change the fmt for that).
~Hans
_______________________________________________
pmwiki-users mailing list
pmwiki...@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users
I'ld like to modify how category pages are shown. Today I'm using the following
as Category.GroupHeader
(:pagelist link=Cateogory.{$Name} fmt=simple list=normal:)
The result is a list of pages that belong to the current category. I'll give an
example, let's say the current category is 'Movies', and the list of pages is
as follows:
* Gone with the wind
* Blues Brothers
* Red planet
What I would like is to also be able to see what (other) categories these pages
belong to, e.g. like this:
* Gone with the wind ([[!Movies]], [[!Drama]])
* Blues Brothers ([[!Movies]], [[!Musical]])
* Red planet ([[!Movies]], [[!Science Fiction]]
Any ideas on how to do this?
Is there a way to get a list of which categories a partuclar page belongs to?
/Christian
--
Christian Ridderström, +46-8-768 39 44 http://www.md.kth.se/~chr
I suggest making a page variable for this:
$FmtPV['$CategoryList'] = 'CategoryList($pagename, $page)';
function CategoryList($pagename, $page) {
preg_match_all('/(?:^|,)Category\.([^,]+)/', $page['targets'], $x);
$out = '';
foreach ($x[1] as $n) {
$out .= "[[!$n]] ";
}
return $out;
}
See http://www.pmwiki.org/wiki/Test/CategoryPV for a demo.
Pm
{(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...
Randy
On Feb 28, 2008, at 4:23 PM, Patrick R. Michaud wrote:
>
> If it's still not working for you... what version of PmWiki
> are you using?
Just to verify: $CategoryList will only work for the last _saved_
version of a page -- i.e., using "preview" from an edit page
won't use the categories in the current edit window.
If it's still not working for you... what version of PmWiki
are you using?
Pm