[opencms-dev] How to add pdf,doc,ppt file into category
Paul-Inge Flakstad
flakstad at npolar.no
Fri Oct 31 13:59:51 CET 2014
Hi again,
I think <cms:contentload ...> is limited to loading XML content ("structured content"), and binary files like PDFs are of course not XML content.
Personally I prefer scriptlet code over expression language, and in the past I've just utilized the CmsCategoryService#readCategoryResources() methods for what you're trying to accomplish.
Something like this (from memory and simplified - not tested!):
<%
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 = readCategoryResources(cmso, "/_categories/mycategory/", true, "/");
// 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();
// Here, you could check the file type ID and/or file extension, and do something
// based on that info. For example, you could group PDF and DOC files separately, or
// discard all files other than PDFs, and so on.
String uri = cmso.getSitePath(r);
%>
<li><a href="<%= cms.link(uri) %>"><%= cms.property(CmsPropertyDefinition.PROPERTY_TITLE, uri, uri) %></a></li>
<%
}
%>
</ul>
<%
} else {
%>
<p>No resources in this category</p>
<%
}
%>
Regarding your config question; just send it to the mailing list, and I'm sure you'll get an answer. :)
Cheers,
Paul
PS: Please keep the subject line intact when replying to the mailing list.
From: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Manoj.Sharma at nevagroup.com
Sent: 31. oktober 2014 13:20
To: opencms-dev at opencms.org
Subject: Re: [opencms-dev] opencms-dev Digest, Vol 157, Issue 5
Hi Paul,
Thanks for valuable reply, Actually i am able to assign categories to pdf, docs etc files. But how to generate dynamic url to these files using function. Like what i am doing for article is:- coded example below:
<ul>
<%-- Define a Solr query --%>
<c:set var="solrQuery">&fq=categoryTypes=testcategory&sort=created asc</c:set>
<%-- Define a create path --%>
<c:set var="createPath">my-article-templates/.content/articles/</c:set>
<%-- Collect the resources --%>
<cms:contentload collector="byContext" param="${solrQuery}|createPath=&{createPath}" preload="true" >
<cms:contentinfo var="info" />
<c:if test="${info.resultSize > 0}">
<cms:contentload editable="true">
<cms:contentaccess var="content" />
<li class="article-li">
<h4 class="article-list margin-bottom-10" style="margin-bottom:7px"><a href="<cms:link>${content.filename}</cms:link>">${content.value.Title}</a></h4>
<%--<p>${content.value.Text}</p>--%>
</li>
</cms:contentload>
</c:if>
<%-- <c:if test="${info.resultSize == 0}">
Nothing found for query:<br/><em>${solrQuery}</em>
</c:if> --%>
</cms:contentload>
</ul>
can i write this type of function for pdf, docs etc. files, so that dynamic url can be generate. I am also have another question regarding opencms configuration if you can help on that than i can post that question too.
With Regards
Manoj Kumar Sharma
opencms-dev Digest, Vol 157, Issue 5
opencms-dev-request
to:
opencms-dev
10/31/2014 04:32 PM
Sent by:
opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>
Please respond to opencms-dev
________________________________
Send opencms-dev mailing list submissions to
opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
or, via email, send a message with subject or body 'help' to
opencms-dev-request at opencms.org<mailto:opencms-dev-request at opencms.org>
You can reach the person managing the list at
opencms-dev-owner at opencms.org<mailto:opencms-dev-owner at opencms.org>
When replying, please edit your Subject line so it is more specific
than "Re: Contents of opencms-dev digest..."
Today's Topics:
1. Re: Is CSS and JS optimization coming to cms:headIncludes in
OpenCms 9.5? (Alessandro Magnolo)
2. OpenCMS 8/9 PDF Link IE8 not working (T.Kluge at t-systems.com<mailto:T.Kluge at t-systems.com>)
3. Using of SOLR timezone parameter (Filip Kratochvil)
4. Re: How to add pdf,doc,ppt file into category (Paul-Inge Flakstad)
----------------------------------------------------------------------
Message: 1
Date: Thu, 30 Oct 2014 13:47:35 +0100
From: Alessandro Magnolo <alessandro.magnolo at gmail.com<mailto:alessandro.magnolo at gmail.com>>
To: The OpenCms mailing list <opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>>
Subject: Re: [opencms-dev] Is CSS and JS optimization coming to
cms:headIncludes in OpenCms 9.5?
Message-ID:
<CA+GGvz_afgQiTEBEU3BwwuVVq74-vqGwdkG1TgE1+YzVLDMyxQ at mail.gmail.com<mailto:CA+GGvz_afgQiTEBEU3BwwuVVq74-vqGwdkG1TgE1+YzVLDMyxQ at mail.gmail.com>>
Content-Type: text/plain; charset=UTF-8
Hello Christian,
in case you're interested, at the next OpenCms days we'll present a
module that, amongst other things, does automatic CSS and JS
minification.
This is the session:
http://www.opencms-days.org/news/Enhancing-OpenCms-front-end-development-with-Sass-and-Grunt/
Regards,
Alessandro Magnolo
On Fri, Sep 19, 2014 at 10:31 PM, Christian Bj?rnbak
<cbj at touristonline.dk<mailto:cbj at touristonline.dk>> wrote:
> Hi
>
> I'm wondering if CSS and JS optimization will be built in to
> cms:headIncludes in OpenCms 9.5?
>
> The WebOptimization v8 module does a similar job but we can't make it work
> in OpenCms 9.0.1.
>
> Besides the cms:headIncludes has the new feature of dynamically collecting
> CSS and JS to add in the <head>.
>
> It would be natural to add the option to optimize the CSS and JS by merging
> the content of the files into one and minify it.
>
> And further could headIncludes be expanded to be able to load the files
> asynchronously.
>
> Is Alkacon or anybody else working on such improvements?
>
> Are they going to be part of or ready around OpenCms 9.5?
>
>
> Med venlig hilsen / Kind regards,
>
> Christian Bj?rnbak
>
> Chefudvikler / Lead Developer
> TouristOnline A/S
> Islands Brygge 43
> 2300 K?benhavn S
> Denmark
> TLF: +45 32888230
> Dir. TLF: +45 32888235
>
> _______________________________________________
> 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/cgi-bin/mailman/listinfo/opencms-dev
>
>
>
>
------------------------------
Message: 2
Date: Thu, 30 Oct 2014 16:32:38 +0100
From: <T.Kluge at t-systems.com<mailto:T.Kluge at t-systems.com>>
To: <opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>>
Subject: [opencms-dev] OpenCMS 8/9 PDF Link IE8 not working
Message-ID:
<901586CA8F92D543BFFFD6E1122F5A36027F664BB59E at HE101453.emea1.cds.t-internal.com<mailto:901586CA8F92D543BFFFD6E1122F5A36027F664BB59E at HE101453.emea1.cds.t-internal.com>>
Content-Type: text/plain; charset="utf-8"
Hi all,
We stuck on a problem that a CMS PDF is not downloadable within IE8 (all other browsers do) from within the cms surflet context.
The http response header looks like this:
HTTP/1.1 200 OK
Date: Thu, 30 Oct 2014 14:16:33 GMT
Server: OpenCms/9.0.1
X-FRAME-OPTIONS: SAMEORIGIN
Cache-Control: no-cache
Pragma: no-cache
Expires: 0
X-UA-Compatible: IE=Edge,chrome=1
Last-Modified: Wed, 29 Oct 2014 13:39:22 GMT
Content-Type: application/pdf
Content-Length: 73340
Via: 1.1 <server>
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
The only workaround that works currently is: setting the export property to true
the response header is then:
HTTP/1.1 200 OK
Date: Thu, 30 Oct 2014 15:08:17 GMT
Server: Apache-Coyote/1.1
X-FRAME-OPTIONS: SAMEORIGIN
Cache-Control: no-cache
Pragma: no-cache
Expires: 0
X-UA-Compatible: IE=Edge,chrome=1
Accept-Ranges: bytes
ETag: W/"1793087-1414681257762"
Last-Modified: Thu, 30 Oct 2014 15:00:57 GMT
Content-Type: application/pdf
Content-Length: 1793087
Via: 1.1 slaweb01.atriumberlin.de
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
But this can't be the final solution because, this document would be downloadable without cmslogin
The none working manifest.xml section is:
<file>
<source>sites/default/cnt/home/<path>/<filename></source>
<destination>sites/default/cnt/home/<path>/<filename></destination>
<type>binary</type>
<uuidstructure>fd7e5bcd-5f70-11e4-88e4-f01faf26b604</uuidstructure>
<uuidresource>fd7e5bce-5f70-11e4-88e4-f01faf26b604</uuidresource>
<datelastmodified>Thu, 30 Oct 2014 14:58:34 GMT</datelastmodified>
<userlastmodified>tkluge</userlastmodified>
<datecreated>Wed, 29 Oct 2014 13:39:22 GMT</datecreated>
<usercreated>tkluge</usercreated>
<flags>0</flags>
<properties>
<property>
<name>Title</name>
<value><![CDATA[Download of File]]></value>
</property>
<property>
<name>export</name>
<value><![CDATA[false]]></value>
</property>
</properties>
<relations/>
<accesscontrol/>
</file>
The filesize is 73340
The effect is an empty page with that src content:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type></HEAD>
<BODY></BODY></HTML>
If I press F12 in the download page, the document mode is Quirks.
Any help?
Thanks Thomas
------------------------------
Message: 3
Date: Thu, 30 Oct 2014 22:13:00 +0100
From: "Filip Kratochvil" <filip.kratochvil at nelasoft.cz<mailto:filip.kratochvil at nelasoft.cz>>
To: "The OpenCms mailing list" <opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>>
Subject: [opencms-dev] Using of SOLR timezone parameter
Message-ID: <015c01cff486$4ad48370$e07d8a50$@nelasoft.cz<mailto:015c01cff486$4ad48370$e07d8a50$@nelasoft.cz>>
Content-Type: text/plain; charset="iso-8859-2"
Hi guys,
we would like to change Timezone in the SOLR query by TZ parameter, but it
doesn?t have any effect and we can?t take results.
Wiki:
https://cwiki.apache.org/confluence/display/solr/Working+with+Dates
Part of the query:
. &fq=CurrentDate_cs_mdt:[2014-01-21T17:00:00Z TO
2014-01-22T17:00:00Z]&TZ=Europe/Prague .
Datetime in the xmlcontent have this value:
2014-01-21T17:00:00Z
But i see datetimei n the SOLR index have this value:
2014-01-21T16:00:00Z
So in the real is here +1 hour time warp (depends on server settings???). I
think it?s regular because dates in the SOLR are stored in the UTC. But for
the regular results should be possible to use TZ parameter, but using it
don?t have any effect.
When we use query with -1HOUR correction, we take results:
. &fq=CurrentDate_cs_mdt:[2014-01-21T17:00:00Z-1HOUR TO
2014-01-22T17:00:00Z] .
Or I'm wrong?
Thank you very much for the help and hope to see you at OpenCms Days 2014.
--
Regards
Filip Kratochvil
------------------------------------------------
NELASOFT Technologies, s.r.o.
E-mail: <mailto:filip.kratochvil at nelasoft.cz> filip.kratochvil at nelasoft.cz<mailto:filip.kratochvil at nelasoft.cz>
Web: <http://www.nelasoft.cz<http://www.nelasoft.cz/>> www.nelasoft.cz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141030/c9b8c14c/attachment-0001.html>
------------------------------
Message: 4
Date: Fri, 31 Oct 2014 11:39:26 +0100
From: Paul-Inge Flakstad <flakstad at npolar.no<mailto:flakstad at npolar.no>>
To: The OpenCms mailing list <opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>>
Subject: Re: [opencms-dev] How to add pdf,doc,ppt file into category
Message-ID:
<4D405B4872E4E54A95966E6CF909E7F34C0D52D8B6 at ANTON.nett.npolar<mailto:4D405B4872E4E54A95966E6CF909E7F34C0D52D8B6 at ANTON.nett.npolar>>
Content-Type: text/plain; charset="us-ascii"
Hi Manoj,
How to assign categories for any file in OpenCms:
Right-click the file (or click the file's icon) to open the context menu
-> Select "Relations"
-> Select "Assign categories"
As for "making them available using functions like articles", I'm not sure what you mean, but check out CmsCategoryService - in particular its readCategoryResources(...) methods:
http://files.opencms.org/javadoc/core/org/opencms/relations/CmsCategoryService.html
HTH,
Paul
From: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Manoj.Sharma at nevagroup.com<mailto:Manoj.Sharma at nevagroup.com>
Sent: 27. oktober 2014 13:58
To: opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>
Subject: [opencms-dev] How to add pdf,doc,ppt file into category
Hi All,
How to assign category to pdf, docs, ppt,excel etc file and make theme available using functions like articles.
with regards
Manoj Kumar Sharma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141031/5daab79a/attachment-0001.html>
------------------------------
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
End of opencms-dev Digest, Vol 157, Issue 5
*******************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20141031/934006e4/attachment.htm>
More information about the opencms-dev
mailing list