[opencms-dev] get title of resource with jstl

Yves Glodt yg at mind.lu
Wed Apr 21 09:57:14 CEST 2010


Hi Lynn,

the cms:titleTag was a hypotethical proposal in my original question.

Try to use cms:property, that does what you need:

<cms:property name='Title' file='/en/sitemap.html' /> or
<cms:property name='Title' file='${myVar}' />

read more about it here:
http://www.bng-galiza.org/opencms/opencms/alkacon-documentation/documentation_taglib/docu_tag_property.html

yves

On 21 April 2010 04:00, chapmanl99 <chapmanl99 at aol.com> wrote:

>
> I would like to use this code but give it a variable containing the
> filename.
> I'm trying to produce a list of files in a folder using the Title property
> of each file.  There are several code examples on the web but none that I
> can find work correctly.  This is what I have so far. I used your
> suggestion
> for the two cms tagTitle lines but they produce an error.
>
> <%@ page session="false" buffer="none" import="java.sql.*, com.onr.*,
> java.util.*,org.opencms.search.*, org.opencms.flex.*, org.opencms.util.*,
> org.opencms.jsp.*, org.opencms.frontend.templateone.modules.*,
> org.opencms.main.*, org.opencms.file.*" %>
> <%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
> <jsp:useBean id="cmsUser" class="org.opencms.jsp.CmsJspActionElement">
> <% cmsUser.init(pageContext, request, response); %>
> </jsp:useBean>
> <%
>
> CmsJspActionElement action = new
> CmsJspActionElement(pageContext,request,response);
> CmsObject cms = action.getCmsObject();
>
> try {
>
>        List listFolders =
> cms.getSubFolders(action.info("opencms.request.folder"));
>        CmsFolder cmsfolder= null;
>        for(int i=0;i<listFolders.size();i++){
>                cmsfolder=(CmsFolder) listFolders.get(i);
> %>
>                 "<cms:link
> /<%=cmsfolder.getName()%></cms:link>"><%=cmsfolder.getName()%>
> <%              out.println("<br>");
>        }
>
>        List listFiles =
> cms.getFilesInFolder(action.info("opencms.request.folder"));
>        for(int i=0;i<listFiles.size();i++){
>                CmsFile cmsfile= (CmsFile) listFiles.get(i);
>                String propertyname = "title";
>                String filename = cmsfile.getName();
> %>
>
>                <cms:titleTag file='site-event-reporting.jsp'/>
>                <cms:titleTag file = filename/>
>
>
>                 "<cms:link
> /<%=cmsfile.getName()%></cms:link>"><%=cmsfile.getName()%>
> <%              out.println("<br>");
>        }
>
> } catch (CmsException e) {
>        out.println(e);
> }
> %>
>
>  These two lines in the middle of the code:
>                <cms:titleTag file='site-event-reporting.jsp'/>
>                <cms:titleTag file = filename/>
>
> do not work for me.  I get "No tag "titleTag" defined in the library
> imported with prefix cms" error.  I'm using opencms 6.  Could that be the
> problem.  I would appreciate any help with this.
> Lynn
>
>
>
> Yves Glodt-5 wrote:
> >
> > On Wednesday 18 February 2009, Yves Glodt wrote:
> >> Hello,
> >>
> >> is there a way to get the title of a resource with an opencms tag, à la
> >> <cms:titleTag file="/folder/file.html" /> ?
> >
> > Fool, of course it is!
> >
> > <cms:property name='Title' file='/en/sitemap.html' />
> >
> > doc-reading helps... :-)
> >
> >> best regards,
> >> Yves
> >>
> >>
> >> _______________________________________________
> >> 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
> >
> >
> >
> >
> > _______________________________________________
> > 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
> >
>
> --
> View this message in context:
> http://old.nabble.com/get-title-of-resource-with-jstl-tp22080788p28287942.html
> Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
>
>
> _______________________________________________
> 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/20100421/320047c8/attachment.htm>


More information about the opencms-dev mailing list