[opencms-dev] How to use a navigation

Nguyen La Yen Dung dny at sdcgrp.com
Sat Jul 12 06:12:01 CEST 2003


 Hi,

Thanks for your reply. As your suggestion, here is what I did yesterday.
 
Define 2 navigation: top_nav, and left_nav.
Put them in the same frame template.
Create two new pages to see how the templates work. Here is my result:

 Because we have only one input navigation name, so the navigations
appearing on the top and the left are the same.
 But their behaviours are different;
 The left navigation is "ON" when selected, the top one is  always "OFF".

I don't know how to declare the navigation names for the left, and the top
ones seperately.

Below are my left_nav, and top_nav contents. 
If possible please tell me what wrong I've made.

Thank you,

Yendung


1.left_nav

<?xml version="1.0" encoding="ISO-8859-1"?>
<XMLTEMPLATE>

<naventry>
  <![CDATA[
    <TR>
      <td > 
        <a 
           href="]]><process>navlink</process><![CDATA["
           onmouseover="JavaScript:document.image_]]>
 
<![CDATA[.value=']]><LINK>/system/galleries/pics/pics/</LINK><process>navtex
t</process><![CDATA[_over.gif'"
           onmouseout="JavaScript:document.image_]]>
 
<![CDATA[.value=']]><LINK>/system/galleries/pics/pics/</LINK><process>navtex
t</process><![CDATA[.gif'">
           <img name="image_]]>
 
<![CDATA["src="]]><LINK>/system/galleries/pics/pics/</LINK><process>navtext<
/process><![CDATA[.gif">
        </a>
      </td></TR>
  ]]>
</naventry>

<navcurrent>
  <![CDATA[
    <TR>
      <td>
        <img
 
src="]]><LINK>/system/galleries/pics/pics/</LINK><process>navtext</process><
![CDATA[_over.gif">
      </td></TR>
  ]]>
</navcurrent>
<TEMPLATE>
  <![CDATA[
    <TABLE border=0 width="100%" height="100%" >
       ]]><method name="getNavCurrent"/><![CDATA[
    </TABLE>]]>

</TEMPLATE>
</XMLTEMPLATE>

2.top_nav

<?xml version="1.0" encoding="ISO-8859-1"?>
<XMLTEMPLATE>
<naventry>
  <![CDATA[
      <td align=middle>
        <a 
           href="]]><process>navlink</process><![CDATA["
           onmouseover="JavaScript:document.image_
 
]]><process>count</process><![CDATA[.value=/opencms/opencms/system/galleries
/pics/pics/]]><process>navtext</process>
           <![CDATA[_over.gif"
           onmouseout="JavaScript:document.image_]]>
 
<![CDATA[.value=/opencms/opencms/system/galleries/pics/pics/]]><process>navt
ext</process><![CDATA[.gif">
           <img name="image_]]><![CDATA[ "
 
src="/opencms/opencms/system/galleries/pics/pics/]]><process>navtext</proces
s><![CDATA[.gif">
        </a>
      </td>
  ]]>
</naventry>
<navcurrent>
  <![CDATA[
      <td align=middle>
        <img
 
src="/opencms/opencms/system/galleries/pics/pics/]]><process>navtext</proces
s><![CDATA[.gif">
      </td>
  ]]>
</navcurrent>
<TEMPLATE>
  <![CDATA[
    <TABLE border=0 width="100%" height="100%" align=center>
     <TR>
       ]]><method name="getNavRoot">2</method><![CDATA[
     </TR>
     </TABLE>]]>

</TEMPLATE>
</XMLTEMPLATE>





-----Original Message-----
From: David Seikel [mailto:david.seikel at icemedia.com.au]
Sent: Friday, July 11, 2003 12:07 PM
To: opencms-dev at opencms.org
Subject: Re: [opencms-dev] How to use a navigation


Time for another of my quickie howtos.  Who ever it was that was 
archiving howtos may want to keep this.

Nguyen La Yen Dung wrote:
> But I don't know how to write these templates in XML language.
>  
> If you know howto or have any idea to help me solve the below problem, 
> please guide me.

Note, this applies to XML templates, it may be completely different for 
JSP.  Also note, these are generic instructions, they may not apply to 
your problem.  They may give some clues though.


First you need to define a navigation element or two -

<ELEMENTDEF name="nav">
	<CLASS>com.opencms.defaults.CmsXmlNav</CLASS>
	<TEMPLATE>../elements/navigation</TEMPLATE>
</ELEMENTDEF>

Next, include <ELEMENT name="nav/> in your frametemplate as usual.

Then write elements/navigation, here is a skeleton to fill out -

<XMLTEMPLATE>
     <naventry>
         <![CDATA[
         ]]>
     </naventry>

     <navcurrent>
         <![CDATA[
         ]]>
     </navcurrent>

<TEMPLATE>
<![CDATA[
             ]]><method name="getNavRoot">2</method><![CDATA[
]]>
</TEMPLATE>
</XMLTEMPLATE>

(Insert HTML as needed in the above.)

<naventry> is used for all navigation links except for the currently 
active page, which will use <navcurrent>.  The method getNavRoot is one 
of the many methods you can use to create navigation menus, which one 
you use depends on what you want to do exactly.  To create a second 
navigation menu, define an element called "nav2" that uses a different 
template file and also include it in your frametemplate.

Now for the problems.

OpenCMS's menu code acts differently if it is creating the menu for 
index.html, the jury is still out about wether to call this a bug or a 
feature. For this reason, we have to be carefull about this. It works 
fine for every file except for the index file, where I get different 
results depending on wether it is called index.html or index.jsp. Since 
I am not using JSP, it doesn't really matter what I call it. To get it 
to work as advertised, the index page has to be called index.html in the 
leaf nodes, and index.jsp everywhere else. For example with a directory 
structure like this -

     * project
     *
           o sub1
           o sub2
           o
                 + sub2_1
                 + sub2_2

I need to have these index files for it all to work -

     * project/index.jsp
     * project/sub1/index.html
     * project/sub2/index.jsp
     * project/sub2/sub2_1/index.html
     * project/sub2/sub2_2/index.html

They all use the same template for the navigation element. While I am 
developing this, it is fine as I can keep track of this and change the 
names as needed (adding a new folder inside sub2_1 would require a name 
change for project/sub2/sub2_1/index.html). But we hand this over to the 
client soon, and they may want to add sub folders, and when they do the 
navigation will break.


Only the currently active page uses <navcurrent> ALL others use 
<naventry>, including the current directory.  I got around this by 
changing the com.opencms.defaults.CmsXmlNav java class to do the right 
thing.  Since XML templates are deprecated, I doubt if the authors will 
include this.  I had previously sent in a patch for some other problem 
but received no feedback.  What exactly is the proceedure for submitting 
patches?

_______________________________________________
This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://mail.opencms.org/mailman/listinfo/opencms-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20030712/9bcbede9/attachment.htm>


More information about the opencms-dev mailing list