Forum
Filter by today
Hi,
I'm trying to show today's radio show via content custom on the home page. Because There are future shows in the admin, the code I'm using shows the latest show:
<?php perch_content_custom('Listen', array(
'page'=>'/listen/listen.php',
'template'=>'_home_listen.html',
'sort'=>'date',
'sort-order'=>'DESC',
'count'=>1,
)
); ?>
I've tried adding 'match':
<?php perch_content_custom('Listen', array(
'page'=>'/listen/listen.php',
'template'=>'_home_listen.html',
'filter' => 'date',
'match' => 'between',
'value' => "$today, $past_date",
'sort'=>'date',
'sort-order'=>'DESC',
'count'=>1,
)
); ?>
But that does display anything. Do I need to add anything to the master template re 'today' or is the above wrong?
Thanks!
That's because you are trying to use variables in a string
should be
Have you set your today and past_date variables?
Thanks Dexter.
Do I need to set today and past_date in the master template?? If so, probably not ... I've not tried to exclude future items before.
This is fine, as the variables will be interpolated.
But where are those two variables defined?
Thanks Drew.
I'm not sure they are defined anywhere. I think I was hoping 'today' would always be 'today'. Each show has a date but the client wants to load up a few weeks shows in advance, but have "today's" show appear on the home page.
Hope that makes sense ... currently my code displays the show with the last show added to the db.
Elliot
Today would be, for example:
Right, thanks. This is new to me, but this seems to work:
Seem ok to you Drew?
If it's doing what you want then it's fine.
Just removed 'sort' and 'sort-order' as un-needed with count set to 1 :)
Thanks Drew!