[opencms-dev] How to build a template (Re: Manifest Manual)

twinkle fourrz at yahoo.com
Thu May 18 21:10:18 CEST 2006


Claus,
   
  Wonderful! Your template cod eis simply superb. However, I would like to add the Head navigation as well which will be different from the left nav. 
   
  Example - Head navigation will include HeadNav1, HeadNav2, HeadNav3, HeadNav4
  When I click on HeadNav1 - Left Nav will be the sub pages in HeadNav1 folder
  HeadNav2 will have the sub pages in HeadNav2 filder and so on
   
  Head Navigation contains all images and I add this as a include file in the mytemplate.jsp. The problem is the navigation.jsp does not get displayed and the index.html in the site is blank. If I print the value of size of navList, it is 0. 
   
  Your help will be highly appreciated. Pelase reply. Thanks, in advance
   
  -Twinkle

Claus Priisholm <cpr at codedroids.com> wrote:
  Well, fiddling with manifests is not what I think of as a newbie 
thing... If all you need is to build a template that you can use for 
your pages it is not that complicated (though building templates can be 
one of the major efforts as the requirements for a site can make them 
quite complicated - templateone is such an example):

1. Go to the administration view, select Modules Management. Create a 
new module. Fill in the values, most important is the Package name, for 
this example: "my.module.name" (typically you would use a java package 
inspired naming strategy). The rest you can fill in as you see fit (or 
leave them blank), but do check all the suggested folders so it will 
create the necessary file structure for you.

2. Switch to the explorer view and the "/" site. Go to 
/system/modules/my.module.name. There you have the file structure for 
the module. Go into the "templates" folder and create a new JSP - e.g 
"mytemplate.jsp". Set the Title-property to something useful, e.g. "My 
template", as it is the title you will see when you select a template 
later on when creating new pages for the site.

3. Enter the code, I've included a simple example. But despite its 
simplicity it shows most of the basic steps:


org.opencms.jsp.*, java.util.*, org.opencms.util.*" %>


CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, 
response);

if (cms.template("HEADER")) {

%>






  
    
  


  
}
if (cms.template("CONTENTS")) {
%>



}
if (cms.template("FOOTER")) {
%>





}
%>

I prefer using scriplet code over taglibs, but that is just a personal 
preference (a dislike towards having to learn yet another syntax...) But 
actually you'll probably end up mixing them as you see fit...

The cms.template("XX") statements are not really necessary unless you 
plan using this template as a master for other similar templates 
(typically because you want to replace the CONTENTS part with some 
specific code rather than the text entered by the end user).
But other than that it is probably the simplest template you can get 
away with: It includes the title-property of the page it is used on as 
the window title. It includes a jsp script to build the navigation and 
finally it includes the body-element from the page. Also it enables the 
direct edit function (optional).

4. Just to make it fully functional, here's the navigation.jsp (put in 
the elements-folder). This is actually code to build a sitemap - you'll 
probably end up using the getNavigationXXX stuff differently to suit 
your needs for the navigation:

org.opencms.file.*, org.opencms.jsp.*, org.opencms.util.*" %>
public void buildSiteMap(CmsJspActionElement cms, String uri, 
java.io.Writer out) throws Exception
{
   List navList = cms.getNavigation().getNavigationForFolder(uri);
   if (navList.size() > 0) {

     out.write("\n");

     Iterator navItem = navList.iterator();
     CmsJspNavElement nav;
     while (navItem.hasNext()) {
       nav = (CmsJspNavElement) navItem.next();
       String navText = nav.getNavText();
       String navPath = nav.getResourceName();
       if (nav.isFolderLink()) {
         out.write("
   " + navText + 
"\n");
         buildSiteMap(cms, navPath, out); // recurse...
       } else {
         out.write("
   " + navText + 
"\n");
       }
     }

     out.write("
\n");
   }
}
%>

CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, 
response);
buildSiteMap(cms, "/", out);

%>

5. Switch to the "/sites/default/" site and create a new page - you can 
now select "My template" as the template for the page. And then you're 
ready to rock...

regards
Claus

Holger Schick wrote:
> Hello,
> well i did my first template. overall i took me hours - but only to find errors like editing the following attributes wrong.
> I used a wrong order= and id= attribute value. I couldn't find a documentation where i can find id- and order numbers which i can use. 
> 
> 
> 
> 
> Another Error was because of all the copy and paste a pasted a already used uuid. The Exception was not while importing an invalid id or something. I retreived a marshalling exception because the module used the wrong xsd. I found the reason in the import module protocol. There was a file name which i didn't wanted to import.
> 
> What are your experiences with open cms? Are this typical newbies errors or do you have also such errors even if you are working already with open cms?
> Or is the only reason that i couldn't find a good documentation and somewhere is one?
> Is there anywhere more documentation available for the manifest.xml or really good community web sites? 
> Is there also a build tool for the manifest available something like a ant script?
> 
> 
> thanks 
> 
> Holger
> _______________________________________________________________
> SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
> kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192
> 
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
> 

-- 
Claus Priisholm, CodeDroids ApS
Phone: +45 48 22 46 46
cpr (you know what) codedroids.com - http://www.codedroids.com
cpr (you know what) interlet.dk - http://www.interlet.dk
--
Javadocs and other OpenCms stuff: 
http://www.codedroids.com/community/opencms

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060518/b0f1a1b0/attachment.htm>


More information about the opencms-dev mailing list