Slaven Rezić > WE_Framework-0.097_03 > WE_Frontend::Plugin::KeywordIndex

Download:
WE_Framework-0.097_03.tar.gz

Dependencies

Annotate this POD

Module Version: 1.03   Source  

NAME ^

WE_Frontend::Plugin::KeywordIndex - gather site keywords

SYNOPSIS ^

    my $t = Template->new({PLUGIN_BASE => "WE_Frontend::Plugin"});

    [% USE KeywordIndex %]
    [% SET keywords = KeywordIndex.array() %]

DESCRIPTION ^

Gather keywords and return them to the templating system.

METHODS

array()

Format and output the given text definition.

EXAMPLES ^

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:

keywordtable

for the whole table

chartitle

for the initial character titles

keyword

for the keyword itself

reference

for the reference (usually a page title)

reflink

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>

AUTHOR ^

Slaven Rezic - slaven@rezic.de

SEE ALSO ^

Template::Plugin.

syntax highlighting: