Reputation: 13558
I'm developing a website using OpenCMS and am having a problem with creating links to files over which I loop using cms:contentload:
<cms:contentload collector="allInFolder" param="faqs/|FaqFile" editable="false">
<b><a href="${opencms.filename}"><cms:contentshow element="Title" /></a></b><br />
</cms:contentload>
This is a part of the index.jsp file. All the links unfortunately lead to index.jsp and not to the individual FAQ files. Do you know how to change this so that it works as expected?
Thanks, John
Upvotes: 1
Views: 2018
Reputation: 1767
In Opencms when you want to link to any resource you have to surround it by the cms:link tag this way:
<cms:link>resource path</cms:link>
You can also do that through OpenCms API:
<jsp:useBean id="cms" class="org.opencms.jsp.CmsJspActionElement">
<% cms.init(pageContext, request, response); %>
</jsp:useBean>
<% **String link = cms.link(resource path)** %>
Upvotes: 0
Reputation: 13558
This is actually a better (and now recommended) way of doing it:
<cms:contentload collector="allInFolder" param="faqs/|FaqFile" editable="false">
<cms:contentaccess var="faqfiles" />
<b><a href="<cms:link>${faqfiles.filename}</cms:link>"><c:out value="${faqfiles.value['Title']}" /></a></b><br />
</cms:contentload>
Upvotes: 3
Reputation: 13558
In the end I solved the problem by changing the link into:
<a href="<cms:link><cms:contentshow element="%(opencms.filename)" /></cms:link>">
It's working now.
Upvotes: 0