[opencms-dev] include xmlpage content from template
Paul-Inge Flakstad
flakstad at npolar.no
Fri Feb 12 11:49:08 CET 2010
Hi Yogesh
Like Eska was pointing out, it is important to use correct file names. In your property, you should put the entire site path of your tip file, like so:
/mylocale/myfolder/myfile.html
NOT like so:
/opencms/opencms/sites/sitename/mylocale/myfolder/myfile.html
/sites/sitename/mylocale/myfolder/myfile.html
I have tested your situation, and here's a solution (tested, works):
In your <cms:template element="insider_tip">, place this to include the xmlpage tip file, replacing all your scriptlet code there:
<cms:include element="body"><cms:property name="tip_file" /></cms:include><!-- you'll need to put the tip file's entire site path in the property tip_file -->
Make sure you change the element="body" to match your xmlpage element.
Alternatively:
keep your scriptlet code as it was, but replace the last scriptlet line to:
<cms:include file="<%= cms.property("tip_file") %>" element="body" /><!-- if the tip file's entire site path is in the property -->
or
<cms:include file="<%= foldername.concat(cms.property("tip_file")) %>" element="body" /><!-- if only the tip file name, not the complete site path, is in the property -->
HTH.
Cheers,
Paul
________________________________
From: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Yogesh Mujumdar
Sent: 12. februar 2010 10:51
To: The OpenCms mailing list
Subject: Re: [opencms-dev] include xmlpage content from template
Hi Paul,
Part of the stacktrace is here ..
javax.servlet.ServletException: javax.servlet.jsp.JspException: Error reading resource from path "/opencms/opencms/TAIG/personal/MyTip1.html".
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:837)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
at org.apache.jsp.WEB_002dINF.jsp.offline.system.modules.com_viral_taig_TemplatesV2.templates.Rural_005fV2_jsp._jspService(Rural_005fV2_jsp.java:265)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
I made a xmlpage type file and put some content in it. Applied my template to it by selecting the template dropdown. Then I defined a property by name tip_file by clicking the Advanced button. The property is set to a xmlpage type of file created in the same VFS directory, e.g, mytip.html.
Both the file and the tip file are located in the same site directory
/opencms/opencms/TAIG/personal/
The template has the following line...
<cms:include file="../elements/commons_v2.jsp" element="insider_tip"/>
The included elements file has the code....
<cms:template element="insider_tip">
<div class="rightnav_content_head"><img
src="<cms:link>../resources/images/right_nav.gif</cms:link>" width="8"
height="8" /> Insider Tip</div>
<div class="rightnav_div1"><!-- --></div>
<div class="rightnav_content">
<%
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
String filename = cms.getRequestContext().getUri();
String foldername = org.opencms.file.CmsResource.getFolderPath(filename);
String tfilename = cms.property("tip_file", filename);
cms.include(cms.link(foldername + tfilename));
%>
<br />
<input type="image"
src="<cms:link>../resources/images/find_out_more.gif</cms:link>"
width="107" height="28"></div>
</cms:template>
-- Yogesh
Believe with all your heart that how you live your life makes a difference. --Colin Beavan
On Fri, Feb 12, 2010 at 3:02 PM, Paul-Inge Flakstad <flakstad at npolar.no<mailto:flakstad at npolar.no>> wrote:
Hi Yogesh
Unless you want to use hard coded file names, using properties such a job sounds about right.
Can you paste the complete error message? Also, please inform what you set the property value to, and where the tip file is located.
I suspect that you will need to use a JSP file - typically the tip_file's template (which is usually found as the property template-elements) - to render the content of your tip file. You would then include this JSP file inside your template code, not the tip file itself. Note that I am not totally sure of this, as I rarely use the xmlpage myself.
Best regards,
Paul
________________________________
From: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] On Behalf Of Yogesh Mujumdar
Sent: 12. februar 2010 09:34
To: opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>
Subject: [opencms-dev] include xmlpage content from template
Dear All,
I have a simple template which is supposed to show the page content. The template has a Tips section where I need to display tips. These requirement is that the tips have to be editable at page level. Tips will be HTML content(xmlpage).
The solution that I came across(which does not work) was to define a property called as tip_file for every page and specify a file name which needs to be shown as a tip. In the template I get the property(tip_file) of the page and make a URI to the file using the context uri and foldername and the tip filename. I then include this file in the template with include method of CmsJspActionElement object. When I view the file with tip_file property set to some xmlpage, I get and error which says "/opencms/opencms/test/mytip.html" is not accessible, though it is available in the folder and is accessible if viewed independently.
Any other quick and smart way of doing it?
-- Yogesh
Believe with all your heart that how you live your life makes a difference. --Colin Beavan
_______________________________________________
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100212/db0dce68/attachment.htm>
More information about the opencms-dev
mailing list