[opencms-dev] The element "body" is not for template "xx"

Chirouze Olivier olivier.chirouze at volvo.com
Fri Aug 1 10:08:31 CEST 2008


Hmm... Come on guys, that wasn't so complicated!

I found the solution, a bit by chance. It seems you simply have to specify the template elements that your template contains.

Even though you might have <cms:template element="ELEMENT1"> tags in your jsp file, that's not enough.
You need to describe these elements so that OpenCms uses them!

So... The solution is... Add the list of template elements to the "template-elements" property of your JSP template file. The format is of form: ELEMENT1|Description 1,ELEMENT2|Description 2 and so on. For instance, for the "simple template", I added: head|Head Element,body|Body Element,foot|Foot Element and it finally worked.
To do this, you will have to right click on the file, choose "Properties", and then "Advanced".

I don't know if OpenCms is supposed to generate that list automatically, or if you need to write it yourself, but unfortunately, that is one more thing I really didn't find in any documentation!

Olivier
 

> -----Original Message-----
> From: Chirouze Olivier 
> Sent: 30 July 2008 10:34
> To: 'The OpenCms mailing list'
> Subject: RE: [opencms-dev] The element "body" is not for template "xx"
> 
> I had to debug OpenCms (again) and so far, here's what I have found:
> 
> When trying to "validate" my element value (body or text1), 
> the list of "elements" in my template is always empty. It 
> seems this list is updated when we save the file, I guess, 
> since OpenCms tries to get the list of elements directly from 
> the database (the parsing is not done at that step).
> 
> So... OpenCms coders/experts, could you please help me: why 
> is there not a single element registered in database for my 
> template jsp file, even if I just copy/paste the content of 
> the example template??
> 
> I also tried to export my module, hoping that was the pb. No change.
> 
> Do I have to set an export point? I would'nt see why, but...
> 
> Thanks
> 
> Olivier
> 
> > -----Original Message-----
> > From: Chirouze Olivier 
> > Sent: 30 July 2008 09:22
> > To: 'The OpenCms mailing list'
> > Subject: RE: [opencms-dev] The element "body" is not for 
> template "xx"
> > 
> > No more luck.
> > 
> > I just copied / pasted the content of "simple JSP template" 
> > from Alakcon documentation to my template. That doesn't work 
> > either, with "body" or "text1".
> > 
> > Did anything change in 7.0.5?
> > 
> > Thanks
> > 
> > Olivier
> > 
> > Olivier CHIROUZE
> > I&0 Infrastructure
> > Volvo Information Technology
> >  
> > 
> > > -----Original Message-----
> > > From: opencms-dev-bounces at opencms.org 
> > > [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Isaac 
> > R. Higgins
> > > Sent: 29 July 2008 17:38
> > > To: The OpenCms mailing list
> > > Subject: RE: [opencms-dev] The element "body" is not for 
> > template "xx"
> > > 
> > > 
> > > try "text1"
> > > 
> > > -----Original Message-----
> > > From: opencms-dev-bounces at opencms.org on behalf of 
> Chirouze Olivier
> > > Sent: Tue 7/29/2008 11:25 AM
> > > To: The OpenCms mailing list
> > > Subject: [opencms-dev] The element "body" is not for template "xx"
> > >  
> > > Hi list,
> > > 
> > > It seems I'm not the first to ask, but I'd like someone in 
> > > the list to be the first to answer ;-)
> > > 
> > > http://www.opencms-forum.de/opencms-forum/viewthread;jsessioni
> > > d=850A87B21AE682373B27EAB41F694A69?thread=1072
> > > http://www.opencms-forum.de/opencms-forum/viewthread;jsessioni
> > > d=2164A8FCCA0565FC64667714BE00FEA8?thread=1175
> > > 
> > > I created a simple template jsp file and am trying to import 
> > > html files with the extended html import as suggested here.
> > > 
> > > However I can't manage to have it work, keep getting this 
> > > error : The element "body" is not for template "xx".
> > > 
> > > Importing the same files with default template (template two) 
> > > works. Creating a new "file with free text" based on my 
> > > template also works.
> > > 
> > > My template is very simple, here's how it looks like (I tried 
> > > with and without the <cms:include element="body" 
> > > editable="true"/> but that didn't change a thing).
> > > 
> > > Thanks for your help!!
> > > 
> > > Olivier
> > > 
> > > <%@ page session="false" %>
> > > <%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
> > > 
> > > <cms:template element="head">
> > > 
> > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
> > > Transitional//EN" 
> > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > > <html xmlns="http://www.w3.org/1999/xhtml">
> > > <head>
> > > <meta http-equiv="Content-Type" content="text/html; 
> > > charset=iso-8859-1" />
> > > <title><cms:property name="title" escapeHtml="true" /></title>
> > > 
> > > 
> > > <meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; 
> > > CHARSET=<cms:property name="content-encoding" 
> > > default="ISO-8859-1" />">
> > > 
> > > 
> > > <body>
> > > 
> > > <!-- Main page body starts here -->
> > > </cms:template>
> > > 
> > > <div class="container">
> > > 
> > > <div class="header"><div class="logo"></div></div>
> > > 
> > > <div class="main">
> > > 	<div class="left">
> > > 	
> > > 		
> > > 	</div>
> > > 	
> > > 	<div class="page">
> > > 		
> > > <cms:template element="body">
> > > 
> > > 	<cms:include element="body" editable="true"/>
> > > 
> > > </cms:template>
> > > 	</div>
> > > 
> > > 	
> > > 
> > > 	
> > > 	<div class="clear"></div>
> > > </div>
> > > 
> > > </div>
> > > 
> > > <cms:template element="foot">
> > > <!-- Main page body ends here -->
> > > 
> > > </body>
> > > </html>
> > > </cms:template>
> > > 
> > > Olivier CHIROUZE
> > > I&0 Infrastructure
> > >  
> > > Volvo Information Technology                                  
> > >                                                            
> > > 402 avenue Charles de Gaulle	* phone: +33 
> > (0)4.72.96.89.39       
> > > API: VNX 0A0 0 02			6 telecopy: +33(0)4.72.96.76.80
> > > 69635 VĂ©nissieux Cedex - France	* 
> > > olivier.chirouze at volvo.com 
> > > <mailto:olivier.chirouze at external.renault-trucks.com> 
> > > 
> > > 
> > > 
> > > 



More information about the opencms-dev mailing list