Hi,
I’m currently developing a part of a site in which the article detail URL looks like this: site.com/{entry_date format='%l_%F_%d_%Y'}
In the detail template I need to parse that segment as a date so I can use is as the entry_date to show the entry of the URL.
Something like: {exp:channel:entries channel="articles" search:entry_date="{segment_2}”}
This won’t work because the entry_date is in unix format.
Any ideas?
Thanks! Lu
Hi LuCmf,
I don’t think, you can achieve proper output using this tag. Either change the date format in URL (lile day/month/year or unix-timestamp) or use PHP in your template.
You can use PHP in template as below :
<?php
$ee =& get_instance();
$seg2 = $ee->uri->segments[2];
$date_arr = explode('_', $seg2);
$date = $date_arr[2].' '.$date_arr[1].' '.$date_arr[3];
$utime = strtotime($date);
?>
{exp:channel:entries channel="articles" search:entry_date="<?php echo $utime; ?>"}you can use year, month, day parameters of channel entry tags also:
<?php
$ee =& get_instance();
$seg2 = $ee->uri->segments[2];
$date_arr = explode('_', $seg2);
$date = $date_arr[2].' '.$date_arr[1].' '.$date_arr[3];
$utime = strtotime($date);
$day = $date_arr[2];
$month = date('m', $utime);
$year = $date_arr[3];
?>
{exp:channel:entries channel="articles" day="<?php echo $day; ?>" month="<?php echo $month; ?>" year="<?php echo $year; ?>"}(Please note: all the code isn’t tested)
Use Template preferences as Allow PHP?:Yes, PHP Parsing Stage:Input
Hope this would help you.
Best Regards,
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.