We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Checkboxes

Development and Programming

Sceneshift's avatar
Sceneshift
39 posts
17 years ago
Sceneshift's avatar Sceneshift

Hello!

I’m trying to use this extension to as a form of key for each of my weblogs. What I’d like to do is take the results and turn them into images, so for each entry in checkbox list, create an <img> tag.

Can anyone explain to me how I would do this?

       
Ian Ebden's avatar
Ian Ebden
312 posts
17 years ago
Ian Ebden's avatar Ian Ebden

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.

       
Macrike's avatar
Macrike
137 posts
16 years ago
Macrike's avatar Macrike

Is it possible to separate the value of the checkbox from the label? I need the checkboxes say for example “Violence, Drugs, Bad Language” but the values of those checkboxes to be “violence, drugs, bad-language”.

       
Adam George's avatar
Adam George
283 posts
16 years ago
Adam George's avatar Adam George

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.

       
Macrike's avatar
Macrike
137 posts
16 years ago
Macrike's avatar Macrike

Thanks Adam, but in the end I just chose to use weblogs and the Playa extension.

       
davidrussell's avatar
davidrussell
102 posts
16 years ago
davidrussell's avatar davidrussell
I’m getting the following all of a sudden (wasn’t doing so before).
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'
Disabling the extension fixes it.

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.

       
davidrussell's avatar
davidrussell
102 posts
16 years ago
davidrussell's avatar davidrussell

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;
    }
       
rccjax's avatar
rccjax
18 posts
16 years ago
rccjax's avatar rccjax

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

       
davidrussell's avatar
davidrussell
102 posts
16 years ago
davidrussell's avatar davidrussell

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.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

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')
       
rccjax's avatar
rccjax
18 posts
16 years ago
rccjax's avatar rccjax

No luck. I’ll dig in a little deeper this week. Initial research may indicate a scope issue with $key.

       
cwpollock's avatar
cwpollock
72 posts
16 years ago
cwpollock's avatar cwpollock

Hi Mark,

Is it possible to configure the checkbox extension to be used on a “Category” custom field, instead of just a weblog custom field. I’m willing to dig into the code and tinker around if you can tell me what direction to head.

Thanks, Chris

       
james Brown's avatar
james Brown
492 posts
16 years ago
james Brown's avatar james Brown

there is a category checkbox extension somewher around here. if you search you will find it.

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg

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.

       
cwpollock's avatar
cwpollock
72 posts
16 years ago
cwpollock's avatar cwpollock
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)

       
First 5 6 7 8

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.