Page 1 of 1

[SOLVED] ListIt2 display items from today

Posted: Sun Aug 04, 2013 5:30 am
by frankmanl
I try to use ListIt2 to display the agenda of a theater. Every item has a performance date, the date on which the show is performed (stored in a date time field as provided by the module).
In this agenda by default past performances should not be displayed, but they should still be available for search queries, so visitors can see what shows were done in the past.
When I set an end date (equal to the performance date) for each performance it will not be shown anymore in the agenda, once that end date is reached - exactly what I want.
BUT ... the item also can't be found by a search query anymore, while I want visitors to be able to see the theater's history.

Would it be possible to have all items in the list available and at the same time to show only items with a performance date bigger than or equal to today's date?

Frank

Re: ListIt2 display items from today

Posted: Sun Aug 04, 2013 4:04 pm
by Dr.CSS
Sounds like a job for News, you can do a search/replace to rename News to something else like Agenda...

Re: ListIt2 display items from today

Posted: Sun Aug 04, 2013 5:06 pm
by frankmanl
I tried News at first instance, but could not get it working, since I also need (custom) fields for date and time (with a date/time picker), advanced file upload (as in GBFilePicker), preferably also for multiselect and currency. I can't make those fields in News, while ListIt2 provides for that when extended by ListIt2XDefs.
If you know a solution to create at least a date/time field (including a date/time picker) and an advanced file uploader for News, I'd be more than happy to use News.

Re: ListIt2 display items from today

Posted: Mon Aug 05, 2013 9:50 am
by Stikki
Yo,

Well time is saved as string format, like all other fielddef data is.

You need to convert it back to timestamp:

{if $item->field_alias|strtotime == $smarty.now}

Compares against fielddef time to current one.

Also, these static attributes available:

$item->create_time
$item->modified_time
$item->start_time
$item->end_time

Re: ListIt2 display items from today

Posted: Sun Aug 11, 2013 9:14 am
by frankmanl
Thanks Stikki, I found out how to use this, I put it in my summary template like this:

Code: Select all

   {* pagination *}

   {* items *}
{foreach from=$items item=item}
   {* show everything till 6 hours after start of concert (=speeldatum) *}
{if ($item->fielddefs['speeldatum'].value|strtotime + 21600) >= $smarty.now}

   {* item *}
<div class="item"><a href="{$item->url}">
   {* field definitions *}
(...)

   {* end item *}

{/if}
{/foreach}
   {* end items *}

   {* pagination *}
This template indeed only shows current and future concerts.