After spending many hours staring at ext.checkbox.php, I haven’t gotten any farther than when this crazy issue began last week. I’m still mesmerized by the strangeness of it all. I’m considering all kinds of wild ideas, like my host changing my database configuration or version. But I can’t fix this without help from someone who can perceive the issue.
Here’s what I do know. The issue must be somewhere inside the ‘modify_template’ function. I narrowed it down to one of the lines that queries the db. It looks as though ‘$row[“weblog_id”]’ is not bringing the weblog_id into the function as it should. Because I am using checkboxes for only one weblog, I hard-coded the ID. That appears to have temporarily treated the issue, but that is obviously no perfect fix and I can’t know whether or not that has an adverse affect.
If anyone can help, I would greatly appreciate it.
function modify_template( $tagdata, $row )
{
global $DB, $TMPL, $EXT;
if($EXT->last_call !== false)
{
$tagdata = $EXT->last_call;
}
$query = $DB->query("SELECT f.field_id, f.field_name, f.field_pre_populate, f.field_pre_blog_id, f.field_pre_field_id FROM exp_weblog_fields AS f, exp_weblogs AS w WHERE w.weblog_id=".$row["weblog_id"]." AND f.group_id=w.field_group AND f.field_type='cbox'");
foreach($query->result as $field)
{
if(isset($row["field_id_".$field["field_id"]]))
{
preg_match_all("/".LD.$field["field_name"]."(.*?)".RD."/", $tagdata, $matches);
foreach($matches[0] as $key=>$match)
{
$items = (preg_match("/[\r\n]+/", $row["field_id_".$field["field_id"]])) ? preg_split("/[\r\n]+/", $row["field_id_".$field["field_id"]]) : array($row["field_id_".$field["field_id"]]);
if($field["field_pre_populate"] == "y" && !preg_match("/[a-zA-Z]/", $row["field_id_".$field["field_id"]]) && trim($row["field_id_".$field["field_id"]]) != "" && count($items) > 0)
{
$query = $DB->query("SELECT entry_id, field_id_".$field["field_pre_field_id"]." AS display FROM exp_weblog_data WHERE weblog_id=".$field["field_pre_blog_id"]." AND entry_id IN(".implode(",", $items).")");
foreach($query->result as $result)
{
$items[array_search($result["entry_id"], $items)] = $result["display"];
}
}
if(isset($this->settings['seperator']) && $this->settings['seperator'] != "")
{
$seperator = $this->settings['seperator'];
}
else if(preg_match("/separator\s*=\s*['\"](.*?)[\"']/", $matches[1][$key], $seperator))
{
$seperator = $seperator[1];
switch($seperator)
{
case '\r':
$seperator = "\r";
break;
case '\n':
$seperator = "\n";
break;
default:
}
}
else
{
$seperator = ", ";
}
$template_data = implode($seperator, $items);
$tagdata = str_replace($match, $template_data, $tagdata);
}
}
}
return $tagdata;
}