normal display article from a date to another date

More
7 years 11 months ago #8688 by Alexandre Legendre
Hi,
Is there a way to display article from a specific period ? I want to create a timeline only for articles published in 2015. Is it possible ? How ?

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #8689 by Kiên
I think you can create a separate category for this article, and only choose category in module.

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago - 7 years 11 months ago #8690 by Alexandre Legendre
I had thought about this solution but It means to create a large number of categories (2015 was only an exemple) and a lot of changes in articles.
I thought about creating in the xml file two fields (begin/end) and use this parameter in the database request to add a "where" on "creation date column.
But I don't know where to find the database request.
Last edit: 7 years 11 months ago by Alexandre Legendre.

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #8691 by Kiên
the query on helper.php and you can setstate for this: $model->setState

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago - 7 years 11 months ago #8692 by Alexandre Legendre
Thanks.
So I have created in the XML file two fields :
<field name="debut" type="calendar" label="Date de début" size="22" format="%Y-%m-%d" filter="user_utc" />
<field name="fin" type="calendar" label="Date de fin" size="22" format="%Y-%m-%d" filter="user_utc" />
In the HELPER, I have added those lines :
$model->setState('filter.datedebut', (int) $params->get('debut'));
$model->setState('filter.datefin', (int) $params->get('fin'));
But I don't know how to set that the articles have to be between "datedebut" and "datefin".
Could you help me ?
Last edit: 7 years 11 months ago by Alexandre Legendre.

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #8693 by Kiên
I think you try again:
Code:
$model->setState('filter.date_filtering', 'range'); $start_date = strtotime((int) $params->get('debut')); $start_date = date("Y-m-d h:i:s", $start_date); $end_date = strtotime((int) $params->get('fin')); $end_date = date("Y-m-d h:i:s", $end_date); $model->setState('filter.start_date_range', $start_date); $model->setState('filter.end_date_range', $end_date);
and remove
Code:
$model->setState('filter.datedebut', (int) $params->get('debut')); $model->setState('filter.datefin', (int) $params->get('fin'));

Please Log in or Create an account to join the conversation.

Time to create page: 0.296 seconds

About Growth

Innovative tech for eCommerce growth

Contact Info

Head: No. 3, 175/55 Lane, Lac Long Quan St., Nghia Do Ward, Cau Giay District, Hanoi City, Vietnam