The Navigation Framework
Table of Contents
Introduction
To goal of the navigation framework is to
- simplify and standardize the generation of navigation widgets like menubars, tabs, breadcrumb paths.
With the approach that is presented here it shall be possible to
- use pre-defined XHTML navigation components and present them with a custom CSS,
- override these components in a publication whereby the logic can be reused, and
- create and integrate new publication-specific navigation components using the same scheme.
Architecture
The navigation framework consists of the following components:
-
/lenya/navigation.xmap
- The sitemap where the navigation components are loaded.
-
/lenya/xslt/navigation/*.xsl
- The default navigation components that are shipped with Lenya.
-
/lenya/pubs/lenya/xslt/navigation/*.xsl
- Custom navigation components of the publication.
Using the Navigation Framework
Loading a Navigation Component
You can load a navigation component from the following URI:
cocoon://navigation/<pub-id>/<component>/<path>.xml
The URI steps are:
-
<pub-id>
- The publicaton ID.
-
<component>
- The navigation component to load (tabs, menu, etc.).
-
<path>
- The navigation path. It is a concatenation of the
href
attributes of the sitetree nodes that lead to the current node, e.g.demo/oscom.html
for the sitetree fragment
<site xmlns="http://apache.org/cocoon/lenya/sitetree/1.0"> <node href="demo/" label="Demo"> <node href="oscom.html" label="OSCOM"/> ... </node> ... </site>
Aggregating the Navigation Components
The basic principle is shown in the following figure:
In the publication sitemap (lenya/pubs/<pub-id>/sitemap.xmap
)
the navigation components are aggregated. Here you decide which components
you want to use:
<map:pipeline> <map:match pattern="navigation/**.html"> (1) <map:aggregate element="page" prefix="page" ns="http://apache.org/cocoon/lenya/cms-page/1.0"> (2) <map:part src="cocoon://navigation/ {publication-id}/breadcrumb/{../1}.html.xml"/> (3) <map:part src="cocoon://navigation/ {publication-id}/tabs/{../1}.html.xml"/> (4) <map:part src="cocoon://navigation/ {publication-id}/menu/{../1}.html.xml"/> </map:aggregate> (5) <map:transform src="xslt/page2xhtml.xsl"> (6) <map:parameter name="root" value="{context}/{publication-id}/"/> </map:transform> (7) <map:serialize type="xhtml"/> </map:match> </map:pipeline>
- The navigation elements are aggregated together with other document parts.
- Load the breadcrumb XHTML fragment.
- Load the tabs XHTML fragment.
- Load the menu XHTML fragment.
- Create the XHTML page.
- The stylesheet can use this parameter to generate absolute URLs.
- Finally, serialize the page as XHTML.
Developing Navigation Components
The following contracts define the development of navigation components:
- A navigation component is an XSLT stylesheet that is located at
-
lenya/xslt/navigation/<component>.xsl
- for default components and
-
lenya/pubs/<publication-id>/lenya/xslt/<component>.xsl
- for default components.
-
- The default components produce an XHTML fragment with the top level element <div class="<component>"/>.