Welcome, Guest
Username: Password: Remember me

TOPIC: display article from a date to another date

display article from a date to another date 6 months 2 weeks ago #8688

  • idpopidpop
  • idpopidpop's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Karma: 0
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 ?
The administrator has disabled public write access.

display article from a date to another date 6 months 2 weeks ago #8689

  • caselock
  • caselock's Avatar
  • OFFLINE
  • Administrator
  • Posts: 228
  • Thank you received: 25
  • Karma: 1
I think you can create a separate category for this article, and only choose category in module.
The administrator has disabled public write access.

display article from a date to another date 6 months 2 weeks ago #8690

  • idpopidpop
  • idpopidpop's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Karma: 0
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: 6 months 2 weeks ago by idpopidpop.
The administrator has disabled public write access.

display article from a date to another date 6 months 2 weeks ago #8691

  • caselock
  • caselock's Avatar
  • OFFLINE
  • Administrator
  • Posts: 228
  • Thank you received: 25
  • Karma: 1
the query on helper.php and you can setstate for this: $model->setState
The administrator has disabled public write access.

display article from a date to another date 6 months 2 weeks ago #8692

  • idpopidpop
  • idpopidpop's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Karma: 0
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: 6 months 2 weeks ago by idpopidpop.
The administrator has disabled public write access.

display article from a date to another date 6 months 2 weeks ago #8693

  • caselock
  • caselock's Avatar
  • OFFLINE
  • Administrator
  • Posts: 228
  • Thank you received: 25
  • Karma: 1
I think you try again:
    $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
$model->setState('filter.datedebut', (int) $params->get('debut'));
$model->setState('filter.datefin', (int) $params->get('fin'));
The administrator has disabled public write access.

display article from a date to another date 6 months 2 weeks ago #8694

  • idpopidpop
  • idpopidpop's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Karma: 0
Thanks for your quick answer. Unfortunately this doesn't work. The result is empty.
The administrator has disabled public write access.

display article from a date to another date 6 months 2 weeks ago #8695

  • caselock
  • caselock's Avatar
  • OFFLINE
  • Administrator
  • Posts: 228
  • Thank you received: 25
  • Karma: 1
Try again :)
    $model->setState('filter.date_filtering', 'range');
    $model->setState('filter.start_date_range', $params->get('debut'));
    $model->setState('filter.end_date_range', $params->get('fin'));
with $params->get('debut') and $params->get('fin') format: "Y-m-d h:i:s"
The administrator has disabled public write access.

display article from a date to another date 6 months 2 weeks ago #8696

  • idpopidpop
  • idpopidpop's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Karma: 0
It looks like it works!! Thanks a lot. I will do further tests before closing this ticket.
The administrator has disabled public write access.
Time to create page: 0.167 seconds