Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2015-07-01 07:18:01
- raminrahimi
- Member
- From: India
- Registered: 2013-03-19
- Posts: 276
how to filter articles by month in jalali format
Here I can filter the articles by specific months of Gregorian
but i want to filter by jalali months (etc_date)
any one plz help
Offline
Re: how to filter articles by month in jalali format
That’s tricky, but if you use etc_date
, a brute-force solution could be:
<txp:php>
list($year, $month) = array_map('intval', do_list(gps('date'), '-') + array(null, 1));
if($year <= 0) $year = intval(etc_date_jalali ('%Y', time()));
if($month <1 || $month > 12) $month = 1;
$gMonth = $month + 2;
$gYear = $year + 621;
while($gMonth > 12) {$gYear += 1; $gMonth -= 12;}
$tstart = strtotime("$gYear-$gMonth-18");
while(etc_date_jalali ('%m', $tstart) != $month) $tstart += 86400;
$tstop = $tstart + 33*86400;
while(etc_date_jalali ('%m', $tstop) != $month) $tstop -= 86400;
$tstart = strftime('%Y-%m-%d', $tstart);
$tstop = strftime('%Y-%m-%d', $tstop);
parse("<txp:variable name='start' value='$tstart' />");
parse("<txp:variable name='stop' value='$tstop' />");
</txp:php>
The variables start
and stop
should now contain Gregorian dates corresponding to the first and the last day of a Jalali month (e.g. 1394-04
) given by URL date
parameter. You can plug them in some db querying plugin:
<txp:smd_query where='Posted BETWEEN ''<txp:variable name="start" />'' AND ''<txp:variable name="stop" />''' ... />
Last edited by etc (2015-07-02 14:38:22)
Offline