[opencms-dev] opencms-dev Digest, Vol 136, Issue 1

Atle Enersen atle.enersen at gmail.com
Sat Dec 7 12:00:15 CET 2024



Alt godt, hilsen Atle Enersen. 
-- 
Telefon: +47 48 06 31 71 

Today's Topics:
1. Re: Extracting Copyright-value (Atle Enersen)

Helo good people.

Still at the same problem, but I think I am getting closer...

In the code pasted below I am trying to fetch an images copyright-value:

<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
        <% 
            org.opencms.jsp.CmsJspActionElement cmsElem = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response);
            org.opencms.file.CmsObject cmsObject = cmsElem.getCmsObject();
            String currentUri = cmsObject.getRequestContext().getUri();
            String imageUri = cmsObject.readPropertyObject("ImageTop", currentUri, true).getValue();
            String copyright = cmsObject.readPropertyObject("Copyright", currentUri, true).getValue();
            out.println("<p><strong>Image URI:</strong> " + imageUri + "</p>");
            out.println("<p><strong>Copyright:</strong> " + copyright + "</p>");
        %>

It failes with this exception: Container-page element "/sites/enersen/.content/enersenarticlesimple/enersenarticlesimple_00004.xml" could not be rendered with formatter "/system/modules/org.enersen.core/formatters/enersenarticlesimple.jsp".

org.apache.jasper.JasperException: javax.servlet.ServletException: org.opencms.file.CmsVfsResourceNotFoundException: Error reading resource from path "/ImageTop".

Any help would be appreciated.

Best regards, Atle.


----------------------------------------------------------------------


Message: 1
Date: Mon, 2 Dec 2024 06:13:47 +0000
From: Atle Enersen <atle.enersen at gmail.com <mailto:atle.enersen at gmail.com>>
To: "opencms-dev at opencms.org <mailto:opencms-dev at opencms.org>" <opencms-dev at opencms.org <mailto:opencms-dev at opencms.org>>
Subject: Re: [opencms-dev] Extracting Copyright-value
Message-ID:
<VI1PR10MB206348E7B3E8AF7E67B82F64A9352 at VI1PR10MB2063.EURPRD10.PROD.OUTLOOK.COM <mailto:VI1PR10MB206348E7B3E8AF7E67B82F64A9352 at VI1PR10MB2063.EURPRD10.PROD.OUTLOOK.COM>>


Content-Type: text/plain; charset="us-ascii"


Thanks, Alex.


But I still have a problem I am afraid. I am not able to extract the actual path of the image, or the image name. Here noted as "path-to-your-image".


Alt godt/best regards, hilsen Atle Enersen. 
-- 
Telefon: +47 48 06 31 71 






Today's Topics:


1. Re: Extracting Copyright-value (Alex Kandzior)




You need to read the "Copyright" property from the file resource.


Traditional tag notation:
<c:set var="imageCopyright"><cms:property name="Copyright" file="%path-to-your-image%" default="" /></c:set>


More modern direct EL notation:
<c:set var="imageCopyright" value="${cms.vfs.readResource['%path-to-your-image%'].property['Copyright']}" />


For further inspiration, you may also look here (around line 230):
https://github.com/alkacon/mercury-template/blob/master/alkacon.mercury.template/resources/system/modules/alkacon.mercury.template/tags/image-vars.tag <https://github.com/alkacon/mercury-template/blob/master/alkacon.mercury.template/resources/system/modules/alkacon.mercury.template/tags/image-vars.tag> <https://github.com/alkacon/mercury-template/blob/master/alkacon.mercury.template/resources/system/modules/alkacon.mercury.template/tags/image-vars.tag> <https://github.com/alkacon/mercury-template/blob/master/alkacon.mercury.template/resources/system/modules/alkacon.mercury.template/tags/image-vars.tag>> <https://github.com/alkacon/mercury-template/blob/master/alkacon.mercury.template/resources/system/modules/alkacon.mercury.template/tags/image-vars.tag> <https://github.com/alkacon/mercury-template/blob/master/alkacon.mercury.template/resources/system/modules/alkacon.mercury.template/tags/image-vars.tag>> <https://github.com/alkacon/mercury-template/blob/master/alkacon.mercury.template/resources/system/modules/alkacon.mercury.template/tags/image-vars.tag>> <https://github.com/alkacon/mercury-template/blob/master/alkacon.mercury.template/resources/system/modules/alkacon.mercury.template/tags/image-vars.tag&gt;>>








Kind regards,
Alex.








------------------------------


Subject: Digest Footer


_______________________________________________
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
https://lists.opencms.org/mailman/listinfo/opencms-dev <https://lists.opencms.org/mailman/listinfo/opencms-dev>




------------------------------


End of opencms-dev Digest, Vol 136, Issue 1
*******************************************




More information about the opencms-dev mailing list