Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Andrius Kurtinaitis
How to filter assets by publishing date interval?
1 luglio 2010 1.55
Risposta

Andrius Kurtinaitis

Punteggio: Junior Member

Messaggi: 62

Data di Iscrizione: 24 gennaio 2010

Messaggi recenti

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?
Felix J Christy
RE: How to filter assets by publishing date interval?
1 luglio 2010 2.21
Risposta

Felix J Christy

Punteggio: Regular Member

Messaggi: 111

Data di Iscrizione: 25 agosto 2009

Messaggi recenti

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
Andrius Kurtinaitis
RE: How to filter assets by publishing date interval?
1 luglio 2010 4.14
Risposta

Andrius Kurtinaitis

Punteggio: Junior Member

Messaggi: 62

Data di Iscrizione: 24 gennaio 2010

Messaggi recenti

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?
Felix J Christy
RE: How to filter assets by publishing date interval?
1 luglio 2010 5.23
Risposta

Felix J Christy

Punteggio: Regular Member

Messaggi: 111

Data di Iscrizione: 25 agosto 2009

Messaggi recenti

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
Andrius Kurtinaitis
RE: How to filter assets by publishing date interval?
1 luglio 2010 5.57
Risposta

Andrius Kurtinaitis

Punteggio: Junior Member

Messaggi: 62

Data di Iscrizione: 24 gennaio 2010

Messaggi recenti

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:
1
2<?xml version="1.0" encoding="UTF-8"?>
3<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">
4    <bean id="com.liferay.portlet.asset.service.persistence.AssetEntryFinder" class="lt.sintagma.libis.liferay.portlet.asset.service.persistence.LibisAssetEntryFinderImpl" parent="basePersistence" />
5</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?
Andrius Kurtinaitis
RE: How to filter assets by publishing date interval?
1 luglio 2010 9.53
Risposta

Andrius Kurtinaitis

Punteggio: Junior Member

Messaggi: 62

Data di Iscrizione: 24 gennaio 2010

Messaggi recenti

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?
Felix J Christy
RE: How to filter assets by publishing date interval?
1 luglio 2010 20.49
Risposta

Felix J Christy

Punteggio: Regular Member

Messaggi: 111

Data di Iscrizione: 25 agosto 2009

Messaggi recenti

I guess, accidentally! emoticon

Cheers,
Felix
Sergio Sanchez
RE: How to filter assets by publishing date interval?
15 marzo 2011 2.19
Risposta

Sergio Sanchez

Punteggio: Junior Member

Messaggi: 41

Data di Iscrizione: 3 febbraio 2011

Messaggi recenti

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
Andrius Kurtinaitis
RE: How to filter assets by publishing date interval?
15 marzo 2011 4.10
Risposta

Andrius Kurtinaitis

Punteggio: Junior Member

Messaggi: 62

Data di Iscrizione: 24 gennaio 2010

Messaggi recenti

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:

1WEB-INF/ext-web/docroot/WEB-INF/classes/META-INF/ext-spring.xml
2WEB-INF\classes\lt\sintagma\libis\liferay\portlet\asset\service\persistence\LibisAssetEntryFinderImpl.class
3WEB-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:
 1
 2<%
 3{
 4    String fromDate = request.getParameter("fromDate");
 5    String toDate   = request.getParameter("toDate");
 6
 7    java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy.MM.dd");
 8    java.util.Date dFromDate = null==fromDate ? null : df.parse(fromDate);
 9    java.util.Date dToDate   = null==toDate   ? null : df.parse(toDate);
10
11    assetEntryQuery = new lt.sintagma.libis.liferay.portlet.asset.service.persistence.LibisAssetEntryQuery(assetEntryQuery);
12    ((lt.sintagma.libis.liferay.portlet.asset.service.persistence.LibisAssetEntryQuery)assetEntryQuery).setFromDate(dFromDate);
13    ((lt.sintagma.libis.liferay.portlet.asset.service.persistence.LibisAssetEntryQuery)assetEntryQuery).setToDate(dToDate);
14}
15%>

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
RE: How to filter assets by publishing date interval?
13 aprile 2012 4.19
Risposta

ruchi sharma

Punteggio: Junior Member

Messaggi: 95

Data di Iscrizione: 24 marzo 2011

Messaggi recenti

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