Page 1 of 1
LISE dates entry - only display future
Posted: Tue Nov 24, 2020 3:57 pm
by johnboyuk1
Can somebody help me with this? I have a LISE module I'm using to display events where one of the fields is called 'date and time' and is a LISE 'Select DateTime' field
I'm outputting the module like this:
{LISEEvents orderby='custom_date_and_time|DESC'}
How do I get it to only display dates in the future? Ones that havent passed already?
Thanks!
Re: LISE dates entry - only display future
Posted: Tue Nov 24, 2020 5:07 pm
by DIGI3
If all entries were created in the recent LISE release, the dates are stored as UNIX timestamps so it's as simple as:
Code: Select all
{LISEtest xsrstart_date=$smarty.now}
If entries were created in an older version, then they're stored as datetime (and newer entries might be unix timestamp, depending upon your preference setting) and will be harder to filter using the module tag. In this case I'd probably just do it in the template itself. It's less efficient and will mess up pagination, but can work:
Code: Select all
{foreach from=$items item=item}
{if $item->date|date_format:U > $smarty.now}
do stuff
{else}
{* item is in the past *}
{/if}
{/foreach}
Re: LISE dates entry - only display future
Posted: Tue Nov 24, 2020 5:25 pm
by velden
Latest version(s) of LISE offer some extended filtering:
Code: Select all
New Extended Date Filter Parameters
The filter_year and filter_month parameters have been deprecated and will be removed in the next major version upgrade of LISE. There is a new set of parameters to replace the previous functionality that you can use now with new and extended features. Using any of the old date filtering parameters will disable the use of the extended ones.
(optional) (new) xf_startday = 1 - The day you wish to start to filter by in a range of days. Defaults to current day. (1)
(optional) (new) xf_endday = 30 - The end day in a range of days you wish to filter by. Defaults to current day. (1)
(optional) (new) xf_startmonth = 1 - The month you wish to start to filter by in a range of months. Defaults to current month. (1)
(optional) (new) xf_endmonth = 12 - The end month in a range of months you wish to filter by. Defaults to current month. (1)
(optional) (new) xf_startyear = 1910 - The year you wish to start to filter by in a range of years. Defaults to current year. (1)
(optional) (new) xf_endyear = 2030 - The end year in a range of years you wish to filter by. Defaults to current year. (1)
Notes:
(1) For the date filters to start working you only needs one of the date parameters: all other omitted will default to current time.
But like DIGI3 said: you're dates may be stored in a different format
Re: LISE dates entry - only display future
Posted: Tue Nov 24, 2020 6:45 pm
by velden
Seems those filters are exclusively for the start and end date fields of LISE.
My bad.
Re: LISE dates entry - only display future
Posted: Wed Nov 25, 2020 9:22 am
by johnboyuk1
ah thats a shame, I did wonder if/how I could use xsrstart_date
So, if I go with DIGI3's other option:
Code: Select all
{foreach from=$items item=item}
{if $item->date|date_format:U > $smarty.now}
do stuff
{else}
{* item is in the past *}
{/if}
{/foreach}
Is it ok to leave nothing in between the {else} and {/if}?
Re: LISE dates entry - only display future
Posted: Wed Nov 25, 2020 2:58 pm
by DIGI3
Note that you only need my second option if your entries are stored as formatted dates (old method).
If you don't need the {else} then just omit it entirely: {if x} do stuff {/if}
Re: LISE dates entry - only display future
Posted: Wed Nov 25, 2020 3:36 pm
by johnboyuk1
Hi DIGI3
No - am using the new LISE, not the old... I thought Veldon indicated the xsrstart_date wouldnt work?
It didnt work when I tried it anyway...!
Re: LISE dates entry - only display future
Posted: Wed Nov 25, 2020 3:39 pm
by DIGI3
He was referring to the xf_* ones he shared, not my original suggestion of xsrstart_*, I've tested {LISEtest xsrstart_date=$smarty.now} and it works great for custom date fields.
Re: LISE dates entry - only display future
Posted: Wed Nov 25, 2020 4:17 pm
by johnboyuk1
Hmm - will try again! Though implemented your other method and is working for me anyway
