Hi,
I’m just looking to limit my channel entries tag pair to this month, whatever the current month happens to be. I notice that there is a month and year parameter but you seem to have to hard code the number in which would not suit my purpose?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
July 21, 2012 12:54pm
Subscribe [2]#1 / Jul 21, 2012 12:54pm
Hi,
I’m just looking to limit my channel entries tag pair to this month, whatever the current month happens to be. I notice that there is a month and year parameter but you seem to have to hard code the number in which would not suit my purpose?
#2 / Jul 23, 2012 2:31pm
Hey Jackie,
I found this thread that has a solution to what you’re trying to do.
I tested and modified it slightly to pull from the entry_date of the entry instead of a custom field.
Just change $channel to the channel_id of the channel in question. Enable PHP in your template and set the parsing stage to “input”.
Hopefully this works for you. Let me know if you have any questions.
<?php
// Edit this
$channel = 4;
$field = 'titles.entry_date';
function implode_r($glue, $pieces)
{
$return = "";
if(!is_array($glue)){
$glue = array($glue);
}
$thisLevelGlue = array_shift($glue);
if(!count($glue)) $glue = array($thisLevelGlue);
if(!is_array($pieces)){
return (string) $pieces;
}
foreach($pieces as $sub){
$return .= implode_r($glue, $sub) . $thisLevelGlue;
}
if(count($pieces)) $return = substr($return, 0, strlen($return) -strlen($thisLevelGlue));
return $return;
}
$this->EE =& get_instance();
$month_start = mktime(0, 0, 0, date("m") , 1, date("Y"));;
$month_end = mktime(0, 0, 0, date("m")+1 , 1, date("Y"));;
$results = $this->EE->db->select('titles.entry_id')
->from('exp_channel_titles as titles')
->join('exp_channel_data as data', 'titles.entry_id = data.entry_id')
->where("$field >= $month_start")
->where("$field < $month_end")
->where('titles.channel_id',$channel)
->get()
->result_array();
$ids = implode_r("|", $results);
?>#3 / Jul 23, 2012 2:39pm
Thank you so much Kyle will give this a whirl
#4 / Jul 23, 2012 3:02pm
Keep me posted on how it goes.
Let me know if you have any issues.
Thanks.