App::ZofCMS::Plugin::HTMLFactory::PageToBodyId - plugin to automatically create id="" attributes on <body> depending on the current page
In your Main Config file or ZofCMS Template:
plugins => [ qw/HTMLFactory::PageToBodyId/ ], body_id => 'override', # including the key overrides the plugin's value
In your HTML::Template template:
<tmpl_var escape='html' name='body_id'>
The module is a small plugin for App::ZofCMS. Its purpose is to automatically generate a value for an id="" attribute that is to be put on <body> HTML element; this value would be used to differentiate different pages on the site and is generated from query dir and page parameters.
id=""
<body>
dir
page
This documentation assumes you've read App::ZofCMS, App::ZofCMS::Config and App::ZofCMS::Template
plugins
plugins => [ qw/HTMLFactory::PageToBodyId/ ],
You need to add the plugin to the list of plugins to execute. Unlike many other plugins, the HTMLFactory::PageToBodyId does not require an additional key in the template and will run as long as it is included.
HTMLFactory::PageToBodyId
body_id
The plugin first checks whether or not body_id first-level key was set in either ZofCMS Template or Main Config File. If it exists, plugin stuffs its value under $t->{t}{body_id} (where $t is ZofCMS Template hashref) otherwise, it creates its own from query's dir and page keys and uses that.
$t->{t}{body_id}
$t
To quote HTML specification:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
The plugin replaces any character that doesn't match the criteria with an underscore(_). Most of the time it will be the slashes (/) present in the full page URL.
_
/
After doing invalid character replacement (see above) the plugin prefixes the generated value with word "page". Considering that any page URL would start with a slash, the resulting values would be in the form of page_index, page_somedir_about-us and so on.
page_index
page_somedir_about-us
The plugin sets body_id key in t ZofCMS Template special key, thus you can use <tmpl_var name='body_id'> in any of your HTML::Template templates to obtain the generated ID. The name of the key cannot be changed.
t
<tmpl_var name='body_id'>
App::ZofCMS, App::ZofCMS::Config, App::ZofCMS::Template, http://www.w3.org/TR/html401/types.html#type-name
'Zoffix, <'zoffix at cpan.org'> (http://zoffix.com/, http://haslayout.net/, http://zofdesign.com/)
<'zoffix at cpan.org'>
Please report any bugs or feature requests to bug-app-zofcms-plugin-htmlfactory-pagetobodyid at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-ZofCMS-Plugin-HTMLFactory-PageToBodyId. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-app-zofcms-plugin-htmlfactory-pagetobodyid at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc App::ZofCMS::Plugin::HTMLFactory::PageToBodyId
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-ZofCMS-Plugin-HTMLFactory-PageToBodyId
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/App-ZofCMS-Plugin-HTMLFactory-PageToBodyId
CPAN Ratings
http://cpanratings.perl.org/d/App-ZofCMS-Plugin-HTMLFactory-PageToBodyId
Search CPAN
http://search.cpan.org/dist/App-ZofCMS-Plugin-HTMLFactory-PageToBodyId/
Copyright 2009 'Zoffix, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install App::ZofCMS::Plugin::HTMLFactory::PageToBodyId, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::ZofCMS::Plugin::HTMLFactory::PageToBodyId
CPAN shell
perl -MCPAN -e shell install App::ZofCMS::Plugin::HTMLFactory::PageToBodyId
For more information on module installation, please visit the detailed CPAN module installation guide.