LISE dates entry - only display future

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

LISE dates entry - only display future

Post 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!
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1629
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE dates entry - only display future

Post 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}
Not getting the answer you need? CMSMS support options
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3484
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE dates entry - only display future

Post 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
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3484
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE dates entry - only display future

Post by velden »

Seems those filters are exclusively for the start and end date fields of LISE.

My bad.
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

Re: LISE dates entry - only display future

Post 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}?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1629
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE dates entry - only display future

Post 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}
Not getting the answer you need? CMSMS support options
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

Re: LISE dates entry - only display future

Post 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...!
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1629
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE dates entry - only display future

Post 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.
Not getting the answer you need? CMSMS support options
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

Re: LISE dates entry - only display future

Post by johnboyuk1 »

Hmm - will try again! Though implemented your other method and is working for me anyway ;D
Post Reply

Return to “Modules/Add-Ons”