.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "HTML::Widgets::NavMenu 3pm"
.TH HTML::Widgets::NavMenu 3pm "2013-10-22" "perl v5.18.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
HTML::Widgets::NavMenu \- A Perl Module for Generating HTML Navigation Menus
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use HTML::Widgets::NavMenu;
\&
\& my $nav_menu =
\& HTML::Widgets::NavMenu\->new(
\& \*(Aqpath_info\*(Aq => "/me/",
\& \*(Aqcurrent_host\*(Aq => "default",
\& \*(Aqhosts\*(Aq =>
\& {
\& \*(Aqdefault\*(Aq =>
\& {
\& \*(Aqbase_url\*(Aq => "http://www.hello.com/"
\& },
\& },
\& \*(Aqtree_contents\*(Aq =>
\& {
\& \*(Aqhost\*(Aq => "default",
\& \*(Aqtext\*(Aq => "Top 1",
\& \*(Aqtitle\*(Aq => "T1 Title",
\& \*(Aqexpand_re\*(Aq => "",
\& \*(Aqsubs\*(Aq =>
\& [
\& {
\& \*(Aqtext\*(Aq => "Home",
\& \*(Aqurl\*(Aq => "",
\& },
\& {
\& \*(Aqtext\*(Aq => "About Me",
\& \*(Aqtitle\*(Aq => "About Myself",
\& \*(Aqurl\*(Aq => "me/",
\& },
\& ],
\& },
\& );
\&
\& my $results = $nav_menu\->render();
\&
\& my $nav_menu_html = join("\en", @{$results\->{\*(Aqhtml\*(Aq}});
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This module generates a navigation menu for a site. It can also generate
a complete site map, a path of leading components, and also keeps
track of navigation links (\*(L"Next\*(R", \*(L"Prev\*(R", \*(L"Up\*(R", etc.) You can start from the
example above and see more examples in the tests, and complete working sites
in the Subversion repositories at
and .
.SH "USAGE"
.IX Header "USAGE"
.ie n .SS "my $nav_menu = HTML::Widgets::NavMenu\->new(@args)"
.el .SS "my \f(CW$nav_menu\fP = HTML::Widgets::NavMenu\->new(@args)"
.IX Subsection "my $nav_menu = HTML::Widgets::NavMenu->new(@args)"
To use this module call the constructor with the following named arguments:
.IP "hosts" 4
.IX Item "hosts"
This should be a hash reference that maps host-IDs to another hash reference
that contains information about the hosts. An HTML::Widgets::NavMenu navigation
menu can spread across pages in several hosts, which will link from one to
another using relative URLs if possible and fully-qualified (i.e: \f(CW\*(C`http://\*(C'\fR)
URLs if not.
.Sp
Currently the only key required in the hash is the \f(CW\*(C`base_url\*(C'\fR one that points
to a string containing the absolute \s-1URL\s0 to the sub-site. The base \s-1URL\s0 may
have trailing components if it does not reside on the domain's root directory.
.Sp
An optional key that is required only if you wish to use the \*(L"site_abs\*(R"
url_type (see below), is \f(CW\*(C`trailing_url_base\*(C'\fR, which denotes the component of
the site that appears after the hostname. For \f(CW\*(C`http://www.myhost.com/~myuser/\*(C'\fR
it is \f(CW\*(C`/~myuser/\*(C'\fR.
.Sp
Here's an example for a minimal hosts value:
.Sp
.Vb 8
\& \*(Aqhosts\*(Aq =>
\& {
\& \*(Aqdefault\*(Aq =>
\& {
\& \*(Aqbase_url\*(Aq => "http://www.hello.com/",
\& \*(Aqtrailing_url_base\*(Aq => "/",
\& },
\& },
.Ve
.Sp
And here's a two-hosts value from my personal site, which is spread across
two sites:
.Sp
.Vb 10
\& \*(Aqhosts\*(Aq =>
\& {
\& \*(Aqt2\*(Aq =>
\& {
\& \*(Aqbase_url\*(Aq => "http://www.shlomifish.org/",
\& \*(Aqtrailing_url_base\*(Aq => "/",
\& },
\& \*(Aqvipe\*(Aq =>
\& {
\& \*(Aqbase_url\*(Aq => "http://vipe.technion.ac.il/~shlomif/",
\& \*(Aqtrailing_url_base\*(Aq => "/~shlomif/",
\& },
\& },
.Ve
.IP "current_host" 4
.IX Item "current_host"
This parameter indicate which host-ID of the hosts in \f(CW\*(C`hosts\*(C'\fR is the
one that the page for which the navigation menu should be generated is. This
is important so cross-site and inner-site URLs will be handled correctly.
.IP "path_info" 4
.IX Item "path_info"
This is the path relative to the host's \f(CW\*(C`base_url\*(C'\fR of the currently displayed
page. The path should start with a \*(L"/\*(R"\-character, or otherwise a re-direction
excpetion will be thrown (this is done to aid in using this module from within
\&\s-1CGI\s0 scripts).
.IP "tree_contents" 4
.IX Item "tree_contents"
This item gives the complete tree for the navigation menu. It is a nested
Perl data structure, whose syntax is fully explained in the section
\&\*(L"The Input Tree of Contents\*(R".
.IP "ul_classes" 4
.IX Item "ul_classes"
This is an optional parameter whose value is a reference to an array that
indicates the values of the class="" arguments for the \f(CW\*(C`
\*(C'\fR tags
whose depthes are the indexes of the array.
.Sp
For example, assigning:
.Sp
.Vb 1
\& \*(Aqul_classes\*(Aq => [ "FirstClass", "second myclass", "3C" ],
.Ve
.Sp
Will assign \*(L"FirstClass\*(R" as the class of the top-most ULs, \*(L"second myclass\*(R"
as the classes of the ULs inner to it, and \*(L"3C\*(R" as the class of the ULs inner
to the latter ULs.
.Sp
If classes are undef, the \s-1UL\s0 tag will not contain a class parameter.
.IP "no_leading_dot" 4
.IX Item "no_leading_dot"
When this parameter is set to 1, the object will try to generate URLs that
do not start with \*(L"./\*(R" when possible. That way, the generated markup will
be a little more compact. This option is not enabled by default for
backwards compatibility, but is highly recommended.
.PP
A complete invocation of an HTML::Widgets::NavMenu constructor can be
found in the \s-1SYNOPSIS\s0 above.
.PP
After you _init an instance of the navigation menu object, you need to
get the results using the render function.
.ie n .SS "$results = $nav_menu\->\fIrender()\fP"
.el .SS "\f(CW$results\fP = \f(CW$nav_menu\fP\->\fIrender()\fP"
.IX Subsection "$results = $nav_menu->render()"
\&\fIrender()\fR should be called after a navigation menu object is constructed
to prepare the results and return them. It returns a hash reference with the
following keys:
.IP "'html'" 4
.IX Item "'html'"
This key points to a reference to an array that contains the tags for the
\&\s-1HTML.\s0 One can join these tags to get the full \s-1HTML.\s0 It is possible to
delimit them with newlines, if one wishes the markup to be easier to read.
.IP "'leading_path'" 4
.IX Item "'leading_path'"
This is a reference to an array of node description objects. These indicate the
intermediate pages in the site that lead from the front page to the
current page. The methods supported by the class of these objects is described
below under \*(L"The Node Description Component Class\*(R".
.IP "'nav_links_obj'" 4
.IX Item "'nav_links_obj'"
This points to a hash reference whose keys are link IDs for
the Firefox \*(L"Site Navigation Toolbar\*(R"
( ) and compatible programs,
and its values are Node Description objects. (see \*(L"The Node Description
Class\*(R" below). Here's a sample code that renders the links as
\&\f(CW\*(C`\*(C'\fR into the page header:
.Sp
.Vb 10
\& my $nav_links = $results\->{\*(Aqnav_links_obj\*(Aq};
\& # Sort the keys so their order will be preserved
\& my @keys = (sort { $a cmp $b } keys(%$nav_links));
\& foreach my $key (@keys)
\& {
\& my $value = $nav_links\->{$key};
\& my $url = CGI::escapeHTML($value\->direct_url());
\& my $title = CGI::escapeHTML($value\->title());
\& print {$fh} "\en";
\& }
.Ve
.IP "'nav_links'" 4
.IX Item "'nav_links'"
This points to a hash reference whose keys are link IDs compatible with the
Firefox Site Navigation ( ) and its
values are the URLs to these links. This key/value pair is provided for
backwards compatibility with older versions of HTML::Widgets::NavMenu. In new
code, one is recommended to use \f(CW\*(Aqnav_links_obj\*(Aq\fR instead.
.Sp
This sample code renders the links as \f(CW\*(C`\*(C'\fR into the
page header:
.Sp
.Vb 9
\& my $nav_links = $results\->{\*(Aqnav_links\*(Aq};
\& # Sort the keys so their order will be preserved
\& my @keys = (sort { $a cmp $b } keys(%$nav_links));
\& foreach my $key (@keys)
\& {
\& my $url = $nav_links\->{$key};
\& print {$fh} "\en";
\& }
.Ve
.ie n .SS "$results = $nav_menu\->\fIrender_jquery_treeview()\fP"
.el .SS "\f(CW$results\fP = \f(CW$nav_menu\fP\->\fIrender_jquery_treeview()\fP"
.IX Subsection "$results = $nav_menu->render_jquery_treeview()"
Renders a fully expanded tree suitable for input to JQuery's treeview plugin:
\- otherwise
the same as \fIrender()\fR .
.ie n .SS "$text = $nav_menu\->\fIgen_site_map()\fP"
.el .SS "\f(CW$text\fP = \f(CW$nav_menu\fP\->\fIgen_site_map()\fP"
.IX Subsection "$text = $nav_menu->gen_site_map()"
This function can be called to generate a site map based on the tree of
contents. It returns a reference to an array containing the tags of the
site map.
.ie n .SS "$url = $nav_menu\->get_cross_host_rel_url_ref({...})"
.el .SS "\f(CW$url\fP = \f(CW$nav_menu\fP\->get_cross_host_rel_url_ref({...})"
.IX Subsection "$url = $nav_menu->get_cross_host_rel_url_ref({...})"
This function can be called to calculate a \s-1URL\s0 to a different part of the
site. It accepts four named arguments, passed as a hash-ref:
.IP "'host'" 8
.IX Item "'host'"
This is the host \s-1ID\s0
.IP "'host_url'" 8
.IX Item "'host_url'"
This is \s-1URL\s0 within the host.
.IP "'url_type'" 8
.IX Item "'url_type'"
\&\f(CW\*(Aqrel\*(Aq\fR, \f(CW\*(Aqfull_abs\*(Aq\fR or \f(CW\*(Aqsite_abs\*(Aq\fR.
.IP "'url_is_abs'" 8
.IX Item "'url_is_abs'"
A flag that indicates if \f(CW\*(Aqhost_url\*(Aq\fR is already absolute.
.ie n .SS "$url = $nav_menu\->get_cross_host_rel_url(...)"
.el .SS "\f(CW$url\fP = \f(CW$nav_menu\fP\->get_cross_host_rel_url(...)"
.IX Subsection "$url = $nav_menu->get_cross_host_rel_url(...)"
This is like \fIget_cross_host_rel_url_ref()\fR except that the arguments
are clobbered into the arguments list. It is kept here for compatibility
sake.
.SH "The Input Tree of Contents"
.IX Header "The Input Tree of Contents"
The input tree is a nested Perl data structure that represnets the tree
of the site. Each node is respresented as a Perl hash reference, with its
sub-nodes contained in an array reference of its \f(CW\*(Aqsubs\*(Aq\fR value. A
non-existent \f(CW\*(Aqsubs\*(Aq\fR means that the node is a leaf and has no sub-nodes.
.PP
The top-most node is mostly a dummy node, that just serves as the father
of all other nodes.
.PP
Following is a listing of the possible values inside a node hash and what
their respective values mean.
.IP "'host'" 4
.IX Item "'host'"
This is the host-ID of the host as found in the \f(CW\*(Aqhosts\*(Aq\fR key to the
navigation menu object constructor. It implicitly propagates downwards in the
tree. (i.e: all nodes of the sub-tree spanning from the node will implicitly
have it as their value by default.)
.Sp
Generally, a host must always be specified and so the first node should
specify it.
.IP "'url'" 4
.IX Item "'url'"
This contains the \s-1URL\s0 of the node within the host. The \s-1URL\s0 should not
contain a leading slash. This value does not propagate further.
.Sp
The \s-1URL\s0 should be specified for every nodes except separators and the such.
.IP "'text'" 4
.IX Item "'text'"
This is the text that will be presented to the user as the text of the
link inside the navigation bar. E.g.: if \f(CW\*(Aqtext\*(Aq\fR is \*(L"Hi There\*(R", then the
link will look something like this:
.Sp
.Vb 1
\& Hi There
.Ve
.Sp
Or
.Sp
.Vb 1
\& Hi There
.Ve
.Sp
if it's the current page. Not that this text is rendered into \s-1HTML\s0
as is, and so should be escaped to prevent HTML-injection attacks.
.IP "'title'" 4
.IX Item "'title'"
This is the text of the link tag's title attribute. It is also not
processed and so the user of the module should make sure it is escaped
if needed, to prevent HTML-injection attacks. It is optional, and if not
specified, no title will be presented.
.IP "'subs'" 4
.IX Item "'subs'"
This item, if specified, should point to an array reference containing the
sub-nodes of this item, in order.
.IP "'separator'" 4
.IX Item "'separator'"
This key if specified and true indicate that the item is a separator, which
should just leave a blank line in the \s-1HTML.\s0 It is best to accompany it with
\&\f(CW\*(Aqskip\*(Aq\fR (see below).
.Sp
If \f(CW\*(Aqseparator\*(Aq\fR is specified, it is usually meaningless to specify all
other node keys except \f(CW\*(Aqskip\*(Aq\fR.
.IP "'skip'" 4
.IX Item "'skip'"
This key if true, indicates that the node should be skipped when traversing
site using the Mozilla navigation links. Instead the navigation will move
to the next or previous nodes.
.IP "'hide'" 4
.IX Item "'hide'"
This key if true indicates that the item should be part of the site's flow
and site map, but not displayed in the navigation menu.
.IP "'role'" 4
.IX Item "'role'"
This indicates a role of an item. It is similar to a \s-1CSS\s0 class, or to
DocBook's \*(L"role\*(R" attribute, only induces different \s-1HTML\s0 markup. The vanilla
HTML::Widgets::NavMenu does not distinguish between any roles, but see
HTML::Widgets::NavMenu::HeaderRole.
.IP "'expand'" 4
.IX Item "'expand'"
This specifies a predicate (a Perl value that is evaluated to a boolean
value, see \*(L"Predicate Values\*(R" below.) to be matched against the path and
current host to determine if the navigation menu should be expanded at this
node. If it does, all of the nodes up to it will expand as well.
.IP "'show_always'" 4
.IX Item "'show_always'"
This value if true, indicates that the node and all nodes below it (until
\&'show_always' is explicitly set to false) must be always displayed. Its
function is similar to \f(CW\*(Aqexpand_re\*(Aq\fR but its propagation semantics the
opposite.
.IP "'url_type'" 4
.IX Item "'url_type'"
This specifies the \s-1URL\s0 type to use to render this item. It can be:
.Sp
1. \f(CW"rel"\fR \- the default. This means a fully relative \s-1URL \s0(if possible), like
\&\f(CW"../../me/about.html"\fR.
.Sp
2. \f(CW"site_abs"\fR \- this uses a \s-1URL\s0 absolute to the site, using a slash at
the beginning. Like \f(CW"/~shlomif/me/about.html"\fR. For this to work the current
host needs to have a \f(CW\*(Aqtrailing_url_base\*(Aq\fR value set.
.Sp
3. \f(CW"full_abs"\fR \- this uses a fully qualified \s-1URL \s0(e.g: with \f(CW\*(C`http://\*(C'\fR at
the beginning, even if both the current path and the pointed path belong
to the same host. Something like \f(CW\*(C`http://www.shlomifish.org/me/about.html\*(C'\fR.
.IP "'rec_url_type'" 4
.IX Item "'rec_url_type'"
This is similar to \f(CW\*(Aqurl_type\*(Aq\fR only it recurses, to the sub-tree of the
node. If both \f(CW\*(Aqurl_type\*(Aq\fR and \f(CW\*(Aqrec_url_type\*(Aq\fR are specified for a node,
then the value of \f(CW\*(Aqurl_type\*(Aq\fR will hold.
.IP "'url_is_abs'" 4
.IX Item "'url_is_abs'"
This flag, if true, indicates that the \s-1URL\s0 specified by the \f(CW\*(Aqurl\*(Aq\fR key
is an absolute \s-1URL\s0 like \f(CW\*(C`http://www.myhost.com/\*(C'\fR and should not be
treated as a path within the site. All links to the page associated with
this node will contain the \s-1URL\s0 verbatim.
.Sp
Note that using absolute URLs as part of the site flow is discouraged
because once they are accessed, the navigation within the primary site
is lost. A better idea would be to create a separate page within the
site, that will link to the external \s-1URL.\s0
.IP "li_id" 4
.IX Item "li_id"
This is the \s-1HTML ID\s0 attribute that will be assigned to the specific
\&\f(CW\*(C`
\*(C'\fR tag of the navigation menu. So if you have:
.Sp
.Vb 10
\& \*(Aqtree_contents\*(Aq =>
\& {
\& \*(Aqhost\*(Aq => "default",
\& \*(Aqtext\*(Aq => "Top 1",
\& \*(Aqtitle\*(Aq => "T1 Title",
\& \*(Aqexpand_re\*(Aq => "",
\& \*(Aqsubs\*(Aq =>
\& [
\& {
\& \*(Aqtext\*(Aq => "Home",
\& \*(Aqurl\*(Aq => "",
\& },
\& {
\& \*(Aqtext\*(Aq => "About Me",
\& \*(Aqtitle\*(Aq => "About Myself",
\& \*(Aqurl\*(Aq => "me/",
\& \*(Aqli_id\*(Aq => \*(Aqabout_me\*(Aq,
\& },
\& ],
\& },
.Ve
.Sp
Then the \s-1HTML\s0 for the About me will look something like:
.Sp
.Vb 3
\&
.Ve
.SH "Predicate Values"
.IX Header "Predicate Values"
An explicitly specified predicate value is a hash reference that contains
one of the following three keys with their appropriate values:
.IP "'cb' => \e&predicate_func" 4
.IX Item "'cb' => &predicate_func"
This specifies a sub-routine reference (or \*(L"callback\*(R" or \*(L"cb\*(R"), that will be
called to determine the result of the predicate. It accepts two named arguments
\&\- \f(CW\*(Aqpath_info\*(Aq\fR which is the path of the current page (without the leading
slash) and \f(CW\*(Aqcurrent_host\*(Aq\fR which is the \s-1ID\s0 of the current host.
.Sp
Here is an example for such a callback:
.Sp
.Vb 7
\& sub predicate_cb1
\& {
\& my %args = (@_);
\& my $host = $args{\*(Aqcurrent_host\*(Aq};
\& my $path = $args{\*(Aqpath_info\*(Aq};
\& return (($host eq "true") && ($path eq "mypath/"));
\& }
.Ve
.ie n .IP "'re' => $regexp_string" 4
.el .IP "'re' => \f(CW$regexp_string\fR" 4
.IX Item "'re' => $regexp_string"
This specifies a regular expression to be matched against the path_info
(regardless of what current_host is), to determine the result of the
predicate.
.IP "'bool' => [ 0 | 1 ]" 4
.IX Item "'bool' => [ 0 | 1 ]"
This specifies the constant boolean value of the predicate.
.PP
Note that if \f(CW\*(Aqcb\*(Aq\fR is specified then both \f(CW\*(Aqre\*(Aq\fR and \f(CW\*(Aqbool\*(Aq\fR will
be ignored, and \f(CW\*(Aqre\*(Aq\fR over-rides \f(CW\*(Aqbool\*(Aq\fR.
.PP
Orthogonal to these keys is the \f(CW\*(Aqcapt\*(Aq\fR key which specifies whether this
expansion \*(L"captures\*(R" or not. This is relevant to the behaviour in the
breadcrumbs' trails, if one wants the item to appear there or not. The
default value is true.
.PP
If the predicate is not a hash reference, then HTML::Widgets::NavMenu will
try to guess what it is. If it's a sub-routine reference, it will be an
implicit callback. If it's one of the values \f(CW"0"\fR, \f(CW"1"\fR, \f(CW"yes"\fR,
\&\f(CW"no"\fR, \f(CW"true"\fR, \f(CW"false"\fR, \f(CW"True"\fR, \f(CW"False"\fR it will be considered
a boolean. If it's a different string, a regular expression match will
be attempted. Else, an excpetion will be thrown.
.PP
Here are some examples for predicates:
.PP
.Vb 2
\& # Always expand.
\& \*(Aqexpand\*(Aq => { \*(Aqbool\*(Aq => 1, };
\&
\& # Never expand.
\& \*(Aqexpand\*(Aq => { \*(Aqbool\*(Aq => 0, };
\&
\& # Expand under home/
\& \*(Aqexpand\*(Aq => { \*(Aqre\*(Aq => "^home/" },
\&
\& # Expand under home/ when the current host is "foo"
\& sub expand_path_home_host_foo
\& {
\& my %args = (@_);
\& my $host = $args{\*(Aqcurrent_host\*(Aq};
\& my $path = $args{\*(Aqpath_info\*(Aq};
\& return (($host eq "foo") && ($path =~ m!^home/!));
\& }
\&
\& \*(Aqexpand\*(Aq => { \*(Aqcb\*(Aq => \e&expand_path_home_host_foo, },
.Ve
.SH "The Node Description Class"
.IX Header "The Node Description Class"
When retrieving the leading path or the \f(CW\*(C`nav_links_obj\*(C'\fR, an array of objects
is returned. This section describes the class of these objects, so one will
know how to use them.
.PP
Basically, it is an object that has several accessors. The accessors are:
.IP "host" 4
.IX Item "host"
The host \s-1ID\s0 of this node.
.IP "host_url" 4
.IX Item "host_url"
The \s-1URL\s0 of the node within the host. (one given in its 'url' key).
.IP "label" 4
.IX Item "label"
The label of the node. (one given in its 'text' key). This is not
SGML-escaped.
.IP "title" 4
.IX Item "title"
The title of the node. (that can be assigned to the \s-1URL \s0'title' attribute).
This is not SGML-escaped.
.IP "direct_url" 4
.IX Item "direct_url"
A direct \s-1URL \s0(usable for inclusion in an A tag ) from the current page to this
page.
.IP "url_type" 4
.IX Item "url_type"
This is the \f(CW\*(C`url_type\*(C'\fR (see above) that holds for this node.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
See the article Shlomi Fish wrote for Perl.com for a gentle introduction to
HTML-Widgets-NavMenu:
.PP
.IP "HTML::Widgets::NavMenu::HeaderRole" 4
.IX Item "HTML::Widgets::NavMenu::HeaderRole"
An HTML::Widgets::NavMenu sub-class that contains support for another
role. Used for the navigation menu in .
.IP "HTML::Widget::SideBar" 4
.IX Item "HTML::Widget::SideBar"
A module written by Yosef Meller for maintaining a navigation menu.
HTML::Widgets::NavMenu originally utilized it, but no longer does. This module
does not makes links relative on its own, and tends to generate a lot of
JavaScript code by default. It also does not have too many automated test
scripts.
.IP "HTML::Menu::Hierarchical" 4
.IX Item "HTML::Menu::Hierarchical"
A module by Don Owens for generating hierarchical \s-1HTML\s0 menus. I could not
quite understand its tree traversal semantics, so I ended up not using it. Also
seems to require that each of the tree node will have a unique \s-1ID.\s0
.IP "HTML::Widgets::Menu" 4
.IX Item "HTML::Widgets::Menu"
This module also generates a navigation menu. The \s-1CPAN\s0 version is relatively
old, and the author sent me a newer version. After playing with it a bit, I
realized that I could not get it to do what I want (but I cannot recall
why), so I abandoned it.
.SH "AUTHORS"
.IX Header "AUTHORS"
Shlomi Fish, , .
.SH "THANKS"
.IX Header "THANKS"
Thanks to Yosef Meller () for writing
the module HTML::Widget::SideBar on which initial versions of this modules
were based. (albeit his code is no longer used here).
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
Copyright 2004, Shlomi Fish. All rights reserved.
.PP
You can use, modify and distribute this module under the terms of the \s-1MIT X11\s0
license. ( ).