[pmwiki-users] Checking for keywords

Petko Yotov 5ko at 5ko.fr
Thu Aug 30 21:31:14 CDT 2012

Carlos AB writes:
> Is there a way to check if the keywords directive was used on a page?
> I tried this so far:
> (:if equal {=$Keywords} "":) inside a template
> (:if equal {=$:Keywords} "":) inside a template

This variable is not enabled by default, you need to add to config.php:

  $FmtPV['$Keywords']  => '@$page["keywords"]';

and then, in the wiki page, use (:if equal "{=$Keywords}" "":) with quotes  
around the {=$Keywords}.

> Also and if possible, I would like to check if the title directive was
> used on a page

This is tricky, because if it is not used, a {$Title} directive will be set  
automatically. Something like this may work:

(:if equal "{=$Title}" "{=$Name}":)
A title directive was probably not used.
This will not work for RecentChanges and other translated pages, see XLPage.

Use {=$Namespaced} if you have enabled $SpaceWikiWords.


More information about the pmwiki-users mailing list