Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Display articles base on date range
Hi, I would like to display articles base on date range, for example 2020-06-01 to 2020-06-10.
From what I see the month
attribute is for a single value (day/month/year), is there a syntax also for date range please?
I need to display articles of last week, this week, and next week, is there a simple way of doing that please?
This is what I got so far for getting the dates, but not sure how to use them in the month
attribute, or do I need to use PHP for that?
<txp:php>
global $variable;
$sundayThisWeek = strtotime('last sunday', strtotime('tomorrow'));
$saturdayThisWeek = strtotime('+6 days', $sundayThisWeek);
$sundayLastWeek = strtotime('-7 days', $sundayThisWeek);
$sundayNextWeek = strtotime('next week sunday', strtotime('tomorrow'));
$saturdayNextWeek = strtotime('+7 days', $saturdayThisWeek);
$variable['week_last_start_date'] = date('Y-m-d', $sundayLastWeek);
$variable['week_this_start_date'] = date('Y-m-d', $sundayThisWeek);
$variable['week_next_start_date'] = date('Y-m-d', $sundayNextWeek);
$variable['week_next_end_date'] = date('Y-m-d', $saturdayNextWeek);
</txp:php>
<txp:article_custom section="schedule" form="schedule_item" time="any" expired="1" month='<txp:variable name="week_last_start_date" /> to <txp:variable name="week_next_end_date" />' />
Last edited by THE BLUE DRAGON (2020-06-17 18:11:02)
Offline
Re: Display articles base on date range
Hi, have you tried <txp:article month="2020-06-01" time="+10 days" />
?
Offline
Re: Display articles base on date range
etc wrote #323818:
Hi, have you tried
<txp:article month="2020-06-01" time="+10 days" />
?
Cool thanks, how can I also add any
to the time attribure together with the +days string? I need to also include future articles please.
Offline
Offline
Re: Display articles base on date range
etc wrote #323820:
IIRC, you don’t have to add
any
,+10 days
should replace it. But I need to check.
Thanks, yes I forgot to set the limit
attribute value to include more.
Offline
Pages: 1