Hi all - My SQL and PHP coding is limited, so appreciate your help here. Extension working fine in the CP. Now, in my template I want to output a <ul> of all the options, but add a CSS class (“inactive”) to the <li> of unchecked options. Make sense? So the finished code will look something like:
<ul class="ticklist">
<li>Option</li>
<li class="inactive">Option</li>
<li>Option</li>
<li>Option</li>
</ul>
Had a stab at a few queries, but no joy. Any help much appreciated.
Not sure what version you are using, but in mine…
In Mark’s extension file: ext.checkbox.php Find:
$r .= $DSP->table_qcell("", $DSP->input_checkbox("field_id_".$row["field_id"]."[]", $item, $select).NBS.$item);
You will notice that it’s not actually a label - just text, which is a bit unfortunate. To change it to a label:
$r .= $DSP->table_qcell("", $DSP->input_checkbox("field_id_".$row["field_id"]."[]", $item, $select).'<label for="'.str_replace(' ','_',$item).'">'.$item.'</label>'
Then you will need some php to convert everything to lowercase. However, I’m using an older version, so it might be completely different in the new version.
Good luck.
I’m getting the following all of a sudden (wasn’t doing so before).Disabling the extension fixes it.MySQL ERROR: Error Number: 1064 Description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND f.group_id=w.field_group AND f.field_type='cbox'' at line 1 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= AND f.group_id=w.field_group AND f.field_type='cbox'
I am having this exact issue. Started happening today without any modifications or upgrades at all. Once I noticed it, I upgraded the whole system to the latest build (which needed to be done anyway). When that didn’t fix it, I found some folks experiencing the same problem with Multi Drop-down List. So I disabled Checkboxes and that solved it. It only occurs when I am logged in as Super Admin. I did download and re-install the extension from the first post of the thread, to no avail.
We rely on the Checkboxes plugin, so I’d love a fix for this. Especially since Mark has not responded to wondermonkey’s original message from four months ago that points out this problem.
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;
}
Mark,
I am getting the following errors when I choose to populate the values from another checkbox field:
Notice: Undefined variable: key in /path/extensions/ext.checkbox.php on line 275 Notice: Undefined variable: key in /path/extensions/ext.checkbox.php on line 277 Notice: Undefined variable: key in /path/extensions/ext.checkbox.php on line 280
The checkbox list I am trying to populate from contains 26 values, and the existing checkbox field works fine.
Any ideas? Thanks - GREAT EXTENSION!! rccjax
rccjax I wouldn’t expect much support on issues related to this extension. It appears the extension author has abandoned this thread long ago. Tough thing to see and something I’ve never experienced before in the EE community. Still, good luck to all of us in this thread who have unresolved issues.
Did your host change to mySQL 5? I had that same sort of error on one of my sites “all of a sudden” and I had to slightly modify the SQL query with some parentheses to bring the query up to mySQL 5 standards. It might even be as simple as changing
AND f.group_id=w.field_group AND f.field_type='cbox'
to
AND (f.group_id=w.field_group) AND (f.field_type='cbox')
That’s to make the category tab into checkboxes. My impression is that cwpollock is trying to make the custom fields on categories be checkboxes.
Exactly!! Yeah, I’m not looking for the Category Checkbox extension.. I’m looking to create a custom field on a category that is shown to the user as checkboxes (or a multiselect.. either would be fine)
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.