[opencms-dev] Article link not generting proper by dynamic function

Manoj.Sharma at nevagroup.com Manoj.Sharma at nevagroup.com
Thu Dec 4 07:49:01 CET 2014


Hi All,

i have created a new site in opencms 9, in which i have created a dynamic 
function which will list the resources name and their link. I have created 
an article which is also displaying but the link generated is not correct. 
It it direct link to article, it should be link via detail page which in 
configured in .config file.

Code: 

<%@page buffer = "none" session = "false" trimDirectiveWhitespaces="true" 
import = "org.opencms.jsp.CmsJspActionElement"%>
<%@page import = 
"org.opencms.file.CmsObject,org.opencms.relations.CmsCategoryService, 
org.opencms.file.CmsResource, java.util.List, java.util.Iterator"%>
<%@page import = "org.opencms.file.CmsPropertyDefinition" %>
<%@taglib prefix = "cms" uri="http://www.opencms.org/taglib/cms" %>
<%@taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
CmsJspActionElement cms = new CmsJspActionElement (pageContext, request, 
response);
CmsObject cmso = cms.getCmsObject();

// Get the category service instance
CmsCategoryService cs = CmsCategoryService.getInstance();

// Get resources assigned a specific category. (You could also provide a 
CmsResourceFilter here.)
List<CmsResource> categoryResources = cs.readCategoryResources(cmso, 
"somelink/", true,"/");
%>
<div>
        <div class="headline"><h4>Some Links</h4></div>
        <div class="left-nav">
<%
// First check if there is something to work with
if (!categoryResources.isEmpty()) {
%>
        <ul>
<%
Iterator<CmsResource> i = categoryResources.iterator();
while (i.hasNext()) {
                CmsResource r = i.next();

                String uri = cmso.getSitePath(r);
%>
                        <div>
                                <li class="margin-bottom-10 
left-nav-list"><a href="<%= cms.link(uri) %>"><%= 
cms.property(CmsPropertyDefinition.PROPERTY_TITLE, uri, uri) %></a></li>
                        </div>
<%
}
%>
</ul>
<%
} else {
%>
                <p style="color: #fff;">No resources in this category</p>
<%
}
%>
</div>
</div>

I have configure detail page also for article in which i have specify 
ddarticle as type and a template for articles. I am storing articles in 
.content -> article folder.

Please friends help me out.

With Regards
Manoj Kumar Sharma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20141204/4f6f36b3/attachment.htm>


More information about the opencms-dev mailing list