I’v created the following plugin:
$begrip = array(
'Aikuchi' => 'Kleine tanto zonder tsuba.',
'Ashi' => 'Smalle kanaaltjes van zachter staal uitlopend van de ji tot de hamon.',
'Austeniet' => 'Structuur van staal die nodig is om het staal te kunnen harden',
'Bo\'hi' => 'Ook wel "hi" genoemd. Is een groeve aan de bovenkant van het blad.',
'Bokken' => '(Meestal houten) oefenzwaard',
'Boshi' => 'De zichtbare hardingslijn (hamon) op de kissaki. ',
// This goes long way on with much more definitions, you get the idea
);
$modx->documentOutput = preg_replace(
'/(?<=[>\s(?]|^)('
. implode(
'|',
array_map(
create_function(
'$s',
'return preg_quote($s, "/");'
),
array_keys(
$begrip
)
)
)
. ')(?=[\s.,<)?]|$)/ie',
'\'<dfn title="\' . htmlspecialchars(\$begrip[ucfirst(strtolower(\'$0\'))]) . \'">$0</dfn>\'',
$modx->documentOutput
);Basically, this automatically finds words on pages from the keys of the $begrip array and adds <dfn>-tags with explenation (values of the array) in the title attribute. This is very handy for new people who don’t know all the terminology about swords (which my website is about). Now I only need this in the articles, not on my indexpage, contactpage, and categorypages. So what I need to know is how to exclude those pages from executing the plugin on. Now I probably could use an if-statement on the lower part of the code, but I don’t know which variable to test on. Could someone please help me?