1

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

John Manak
  • 13,328
  • 29
  • 78
  • 119

3 Answers3

3

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>
John Manak
  • 13,328
  • 29
  • 78
  • 119
0

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)** %>
spekdrum
  • 1,559
  • 2
  • 11
  • 15
0

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.

John Manak
  • 13,328
  • 29
  • 78
  • 119