[opencms-dev] Looping over files -> use expression language; macros are triggered by %()

Thomas Decher thomas.decher at tomdigital.de
Fri Mar 19 11:23:30 CET 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello Peter,

first, since version 7.0.0 or so the macros like opencms.filename are marked by
%() instead of ${} to avoid problems with expression language eg.
%(opencms.filename).


Then I would recommend to use expression language instead of cms:contentschow
and cms:contentloop.



Short examples are to find in the javadoc:

http://files.opencms.org/javadoc/core/org/opencms/jsp/util/CmsJspContentAccessBean.html#getValue()
and
http://files.opencms.org/javadoc/core/org/opencms/jsp/util/CmsJspContentAccessBean.html#getValueList()

instead of ${opencms.filename} you should use
http://files.opencms.org/javadoc/core/org/opencms/jsp/util/CmsJspContentAccessBean.html#getFilename()

For more detailed examples have a look at linkbox.jsp, listbox.jsp and
textbox.jsp in the elements folder of the template two demo in the module
org.opencms.frontend.templatetwo


Regards Thommy


Petr Chelčický schrieb:


I'm sorry but unfortunately my webmail client hid the code, so I'm sending it again:

Hi!

 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="ePass/faqs/|FaqFile"
editable="false">
    <%-- create a date object from date value --%>
      <% int i = 0; %>

      <cms:contentcheck ifexists="Subcategories">
      <cms:contentloop element="Subcategories">
         <cms:contentloop element="Faqs">
          <% i++; %>
         </cms:contentloop>
      </cms:contentloop>
     </cms:contentcheck>
     <b><a href="${opencms.filename}"><cms:contentshow element="Title"
/></a></b> (<%= i %> answers) <br />
  </cms:contentload>

 This is 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?

 Thanks,
 Peter


> It seems as if there was a bug in OpenCMS here.  When I make it as simple as this:
> 
> <cms:contentload collector="allInFolder" param="ePass/faqs/|FaqFile" editable="false">
>       <b><a href="${opencms.filename}"><cms:contentshow element="Title" /></a></b><br />
> </cms:contentload>
> 
> opencms.filename doesn't seem to resolve properly. I'm looping over a bunch of files and the macro should resolve to the filename of the FaqFile file currently read, but it always resolves only to the filename of the file in which this loop is made (i.e. it stays the same, "index.jsp"). Is there any workaround to this?
> 
> Peter
> 
> _______________________________________________
> 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

- --
- -
TOM Digital GmbH
Thomas Decher
Hammerbrookstrasse 93
20097 Hamburg, Germany

Fax: +49.40.254048-40

E-Mail: td at tomdigital.de
___________________________________________________________________________

TOM Digital GmbH

Geschäftsführer / Managing Director: Thomas Heisterhagen
Eingetragen beim / registered at: Amtsgericht Hamburg HRB 110797

Diese e-mail einschliesslich ihrer Anlagen ist vertraulich und nur fuer
den Adressaten bestimmt. Wenn Sie nicht der vorgesehene Empfaenger sind,
bitten wir Sie, dieses e-mail mit Anlagen unverzueglich vollstaendig zu
loeschen und uns umgehend zu benachrichtigen.

This e-mail and its attachments are strictly confidential and are
intended solely for the attention of the person to which it is
addressed. If you are not the intended recipient of this e-mail, please
delete it including its attachments immediately and inform us
accordingly.
___________________________________________________________________________
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkujUKIACgkQJ51ior3MhtYY9ACgi4XFReL6cr3NRpnmD+6kwoKc
eEgAn17sLswM3b8HdgF0bCTla09hNvdR
=A2LT
-----END PGP SIGNATURE-----



More information about the opencms-dev mailing list