
WE_Frontend::Plugin::KeywordIndex - gather site keywords

my $t = Template->new({PLUGIN_BASE => "WE_Frontend::Plugin"});
[% USE KeywordIndex %]
[% SET keywords = KeywordIndex.array() %]

Gather keywords and return them to the templating system.
Format and output the given text definition.

Here's a complete example for KeywordIndex. This template snippet creates an alphabetically sorted (case insensitive) list with linked keywords. If there is more than one reference for one keyword, then the links are created in the second column, and the links are labelled with the page titles.
The used classes here are:
for the whole table
for the initial character titles
for the keyword itself
for the reference (usually a page title)
for the link part of a keyword or reference
The templating code:
<noindex><!--htdig_noindex-->
<table class="keywordtable">
[% USE KeywordIndex -%]
[% SET kws = KeywordIndex.array() -%]
[% SET lastchar = " " -%]
[% FOR kwdef = kws -%]
[% SET lastcharmatch = '^(?i:' _ lastchar _ ')' -%]
[% IF !kwdef.Keyword.match(lastcharmatch) -%]
[% SET matches = kwdef.Keyword.match('^(.)') -%]
[% SET lastchar = matches.0 -%]
<tr><td colspan="2" class="chartitle">[% lastchar | upper %]</td></tr>
[% END -%]
<tr>
[% IF kwdef.References.size == 1 -%]
<td class="keyword"><a class="reflink" href="[% kwdef.References.0.Relurl | html_entity %]">[% kwdef.Keyword | html_entity %]</a></td>
[% ELSE -%]
<td class="keyword">[% kwdef.Keyword | html_entity %]</td>
<td class="reference">
[% FOR ref = kwdef.References -%]
<a class="reflink" href="[% ref.Relurl | html_entity %]">[% ref.Title | html_entity %]</a><br>
[% END -%]
</td>
[% END -%]
</tr>
[% END -%]
</table>
<!--/htdig_noindex--></noindex>

Slaven Rezic - slaven@rezic.de
