Foros de discusión

How to filter assets by publishing date interval?

thumbnail
Andrius Kurtinaitis, modificado hace 13 años.

How to filter assets by publishing date interval?

Junior Member Mensajes: 62 Fecha de incorporación: 25/01/10 Mensajes recientes
Hello,

I have to make a news page with many filtering options. One of them is to allow users to select date interval (from-to) and use it for news filtering.

I looked at the asset publisher portlet and its JSPs. It seems that the asset service does not support asset searching using publish date interval (only poublish-expire interval).

Could you please outline a possible solution?
Is the asset publishhing portlet the right way to go?
Custom JSPs and a finder class?

Or it would be better to go some other way?
thumbnail
Felix Joseph Christy, modificado hace 13 años.

RE: How to filter assets by publishing date interval?

Regular Member Mensajes: 111 Fecha de incorporación: 26/08/09 Mensajes recientes
Hi,

From your requirement, I think, there will be only one type of asset, a web content!

Here, the good approach would be :

1) Create web contents with category "News".

2) Customize web content search portlet or create a new portlet to search news, you can use web content's display date for your date interval part.



Cheers,
Felix
thumbnail
Andrius Kurtinaitis, modificado hace 13 años.

RE: How to filter assets by publishing date interval?

Junior Member Mensajes: 62 Fecha de incorporación: 25/01/10 Mensajes recientes
You mean it would not be feasible to use and customize the standard asset publisher plugin, but instead write my own plugin?

This solution would remove the possibility to use the comments, view and filtering customization and other features available in AssetPublisher plugin.

I thought it may be ok to write a custom AssetEntryFinderImpl and an extended AssetEntryQuery with additional two date params and use them in a slightly customized AssetPublisher plugin. Here I feel a little uncomfortable while intervening so much into liferay core. What will I do when a new liferay version comes?

Any thoughts?
thumbnail
Felix Joseph Christy, modificado hace 13 años.

RE: How to filter assets by publishing date interval?

Regular Member Mensajes: 111 Fecha de incorporación: 26/08/09 Mensajes recientes
Oh....

I thought you just want to play with content only, if you want to use features like user comments and all, then you must go for asset publisher only.

You can select the type of content, content with tags.


Cheers,
Felix
thumbnail
Andrius Kurtinaitis, modificado hace 13 años.

RE: How to filter assets by publishing date interval?

Junior Member Mensajes: 62 Fecha de incorporación: 25/01/10 Mensajes recientes
Thanks.
Right now I am trying to inject my custom AssetEntryFinder implementation:

- put file into liferay-portal-6.0.2\tomcat-6.0.26\webapps\ROOT\WEB-INF\classes\META-INF\portal-spring-ext.xml

- with the following contents:

<!--?xml version="1.0" encoding="UTF-8"?-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" default-destroy-method="destroy" default-init-method="afterPropertiesSet" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
	<bean id="com.liferay.portlet.asset.service.persistence.AssetEntryFinder" class="lt.sintagma.libis.liferay.portlet.asset.service.persistence.LibisAssetEntryFinderImpl" parent="basePersistence" />
</beans>


But the liferay still uses the original finder implementation (AssetEntryFinderImpl).
Have I put the file in the wrong place? Does it have wrong name? Where will I find documentation on injecting custom services?
thumbnail
Andrius Kurtinaitis, modificado hace 13 años.

RE: How to filter assets by publishing date interval?

Junior Member Mensajes: 62 Fecha de incorporación: 25/01/10 Mensajes recientes
Solved it. Wrong file name. Must be ext-spring.xml
I must notice that the ext file naming is inconsistent.

Some ext files are named *-ext.*, other ext-*
Is there a reason for this, or is it just accidentally?
thumbnail
Felix Joseph Christy, modificado hace 13 años.

RE: How to filter assets by publishing date interval?

Regular Member Mensajes: 111 Fecha de incorporación: 26/08/09 Mensajes recientes
I guess, accidentally! emoticon

Cheers,
Felix
Sergio Sanchez, modificado hace 13 años.

RE: How to filter assets by publishing date interval?

Junior Member Mensajes: 41 Fecha de incorporación: 3/02/11 Mensajes recientes
Hi emoticon I'm trying to do the same thing, I would like the asset manager be able to find assets between two dates.

How this class overriding the default implementation should be deployed? Inside a hook? If I deploy that class inside a hook I'm getting a ClassNotFoundException.

Thanks for your time
thumbnail
Andrius Kurtinaitis, modificado hace 13 años.

RE: How to filter assets by publishing date interval?

Junior Member Mensajes: 62 Fecha de incorporación: 25/01/10 Mensajes recientes
Sergio Sanchez:

How this class overriding the default implementation should be deployed? Inside a hook? If I deploy that class inside a hook I'm getting a ClassNotFoundException.


A hook does not allow overriding core classes, only services. Therefore my solution is implemented using ext plugin. It consists of three files:

WEB-INF/ext-web/docroot/WEB-INF/classes/META-INF/ext-spring.xml
WEB-INF\classes\lt\sintagma\libis\liferay\portlet\asset\service\persistence\LibisAssetEntryFinderImpl.class
WEB-INF\classes\lt\sintagma\libis\liferay\portlet\asset\service\persistence\LibisAssetEntryQuery.class 


The finder and query classes extend corresponding core classes. The query class is a wrapper for the original query, it is instantiated in view_dynamic_list.jspf:

&lt;% 
{
    String fromDate = request.getParameter("fromDate");
    String toDate   = request.getParameter("toDate");

    java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy.MM.dd");
    java.util.Date dFromDate = null==fromDate ? null : df.parse(fromDate);
    java.util.Date dToDate   = null==toDate   ? null : df.parse(toDate);

    assetEntryQuery = new lt.sintagma.libis.liferay.portlet.asset.service.persistence.LibisAssetEntryQuery(assetEntryQuery);
    ((lt.sintagma.libis.liferay.portlet.asset.service.persistence.LibisAssetEntryQuery)assetEntryQuery).setFromDate(dFromDate);
    ((lt.sintagma.libis.liferay.portlet.asset.service.persistence.LibisAssetEntryQuery)assetEntryQuery).setToDate(dToDate);
}
%&gt;

The finder looks if it gets the custom query and uses date getters.
view_dynamic_list.jspf itself is deployed in a separate hook. I do not like the resulting dependency of the hook on the ext plugin, but it seems, hooks are the Liferays way to override jsp files.
ruchi sharma, modificado hace 12 años.

RE: How to filter assets by publishing date interval?

Junior Member Mensajes: 95 Fecha de incorporación: 24/03/11 Mensajes recientes
Hello Andrius
Your forum is really helpful.
I also want to do the same, but its not completely clear to me.
If possible, is their any document which explains injecting the custom behaviour over default which you have done.
It would be great if you could provide me the three customised files which you have mentioned. So that I can have a look at your configuration stuff.

Thanks
Ruchi