AW: [opencms-dev] navigation
Michael Emmerich
Michael.Emmerich at framfab.de
Wed Dec 19 10:41:21 CET 2001
Hello Bruno,
>I'm reading the "The default navigation class in opencms (1.3.2.)" part of
>the opencms documentation.
>In this document it is said that the master template refers to the
>file "content/internal/navigation" and that this file contains elements
like
>"navlink" or "navtext".
> How and where the elements "navlink" or "navtext" have to be defined?
> Is there a "navigation" file per page as for the master template?
> How to do do the link between the "navigation(s)" file and the pages to be
> called?
To add a navigation you have to define an element that includes a <template>
tag and at least the <naventry> and <navcurrent> tags as in the example
below:
<?xml version="1.0"?> <XMLTEMPLATE>
<naventry>
<![CDATA[
<tr>
<td>
<a href="]]><process>navlink</process><![CDATA[">
]]><process>navtext</process><![CDATA[
</a>
</td>
</tr>
]]>
</naventry>
<navcurrent>
<![CDATA[
<tr>
<td>
]]><process>navtext</process><![CDATA[
</td>
</tr>
]]>
</navcurrent>
<TEMPLATE>
<![CDATA[
<TABLE border width="100\%" height="100\%">
]]><method name="getNavCurrent"/><![CDATA[
</TABLE>
]]>
</TEMPLATE>
</XMLTEMPLATE>
This template should be located in the /content/elements/ folder of your
OpenCms, in this example it is the file named "/content/elements/navigation"
You then have the element that is defined by this temeplate in your
frametemplate, for example this could be done like this:
..
<TD width="80\%" align="center">
]]><element name="contenttemplate"/><![CDATA[
</TD>
..
The last thing to do is to tell the frametemplate, how this element is
defined. This is done by adding the <elementdefinition> to the framtemplate:
<ELEMENTDEF name="nav">
<CLASS>com.opencms.defaults.CmsXmlNav</CLASS>
<TEMPLATE>/content/elements/navigation</TEMPLATE>
</ELEMENTDEF>
By doing this, the navigation element will be inserted in all pages using
this frametemplate. But now lets return to the naviagation element itself.
As in every template, the content of the template itself is defined in the
<template> tag. As you can see in the example, a HTML-table is deinfed in
this tag and inside the table, a OpenCms method is called ("getNavCurrent").
This method is one of the predifined methods of the OpenCms navigation
class, it will create the navigation with all files and folders of the
current folder. The documentation shows all avialble methods of the OpenCms
default navigation class.
What is this method doing? It looks up all files and folders in the current
folder that contain some navigation information, sorts them by their defined
navigation position and replaces the method call in the <template> tag with
the HTML-code that builds the navigation. This is why you need the
<naventry> and <navcurrent> tags. They define how a navigation entry looks
like.
In the example above, the <naventry> tag defines a HTML table row that
contains the Navigation text and a link to the resource that is connected
with this navigation entry. The values for <navlink> and <navtext> are
automatically set by the navigation class, so you do not have to care about
them. The only thing you have to do is to click to the "add to navigation"
checkbox when you create a new page or folder.
The <navcurrent> tag is used to show the navigation entry of the currently
selected page. Normally the selected page is shown differntly in the
navigation (different color, no link to it, etc), so this tag can be used to
define how this entry should look like.
Regards,
Michael Emmerich
More information about the opencms-dev
mailing list