I’ve developed an extension that adds another field to the field types. The field acts the same as a “Drop-down List” however it allows you to select multiple items in the list. Add the extension like normal and modify your settings to control the display of the field in your template.
Good Luck
Mark
Update 5 - Fixed a few bugs when using the pre-populate feature Update 4 - add the option ”{input}” in the admin tab and the publish screen will now contain a text field for quick entries to the field Update 3 - fixed a bug where this extension would delete other fields data before the field got a change to parse it. Update 2 - added the ability to use separator=”[string]” in your template to override the default seperator Update 1 - updated extension to play nice with other extensions using the $EXT->last_call variable
Excellent extension, I have been hoping for something like this for a while.
2 things:
- any particular reason you didn’t include “title” and “url_title” in the list of fields to choose from?
- the link to your documentation shows an empty page.
While you are at it, why not whip up some other field types as well?
- a checkbox field
- radio buttons
I know it is possible to use drop-down select boxes and this extension to achieve the same result, but I’ve heard/seen some requests for it.
# I’m not sure what you mean by title, and url_title, but if you’re talking about pre-populating the field then that wasn’t me, that’s built into EE. I’m not really sure why you can’t pre-populate the field with a title or url title (I guess that’s the job of the relationship field)
# Yup, working on the documentation page now.
As for the checkbox and radio buttons, I think the easiest way to do that would be with drop downs. Adding more custom fields seems redundant and just adds more development, debugging, and support for a process that is already possible with the current fields. One thing I will say, is that I’m going to publish a template for creating custom fields and with that you’re more than welcome to create checkbox and radio button fields.
Thanks for the feedback, glad you liked the extension.
mark
Yup, I was talking about the pre-populating of fields.
Having the possibility to select multiple Titles would allow for some form of “one to many” relationship, especially if the “url_title” is passed to the template as well.
Anyway, I see it works the way EE does, that’s cool.
Again, drop-down fields don’t offer multiple selections, and that is what your extension was designed for right?
So, if would be great to have it do checkboxes as well. (radio buttons don’t allow for multiple selections, my bad)
Looking forward to this template you are talking about, very nice work!
I’m working on a multi-relationship field now, which will serve that “one-to-many” relation you are talking about, I think that’s a better way to go than to re-rig this. I’d like to keep everything pretty separate, there’s no reason for “one field to rule them all”.
Here’s my take on the checkboxes and dropdowns: If you want to offer radio buttons then use a drop-down list (same idea, choose one out of many), if you want to offer checkboxes use a multi drop-down list (same idea, choose as many as you want). The reason for keeping them in drop-down’s is that when the field is posted all the values are stored in an array, however when you use checkboxes you would have to receive many values such as field_id_21_checkbox1, field_id_21_checkbox2, field_id_22_checkbox3. So I guess I’m saying that I’m too lazy to offer checkboxes, and I think the code would get fairly ugly and highly processor intensive, while the drop-down list’s keep it simple.
You’re more than welcome to use my template however, when I post it, to create checkboxes, radio buttons etc.
I agree, if there was a way to allow someone to choose between the list typ (whch you have now) and a set of check boxes that would be so very useful. Although most of us have no problems using the control clicking method to select multiple items, our users can be a different story. Sadly many of the people I build sites for lack the mental ability to do this. But….they can do check boxes!
I’ve posted a quick update to the multi drop down list extension above. It now plays nice with other extensions by using the $EXT->last_call variable. Download it in the first post.
Hello all. I did in fact create the checkbox extension that everyone has been talking about. Let me know how it works for you. One addition I see myself adding is a configurable number of columns, incase your labels are rather long.
Quick note: I’ve added the ability to define a separator in the template tag using separator=”[string]” where [string] can be whatever you’d like your separator to be.
Yes, it is the job of the relationship field. At this time there is no multiple select for relationships though, would love to see title added to this extension
Yes, it is the job of the relationship field. At this time there is no multiple select for relationships though, would love to see title added to this extension
# I’m not sure what you mean by title, and url_title, but if you’re talking about pre-populating the field then that wasn’t me, that’s built into EE. I’m not really sure why you can’t pre-populate the field with a title or url title (I guess that’s the job of the relationship field)
Sorry to re-open this post as it were. Just wanted to say a massive thanks for such a great extension but I was just wondering if anyone could help with a slight problem I have.
The problem is nothing to do with your extension but more a way that I would like to use the data that has been entered by it.
When I use the multi drop down menu in an entry it adds in the ‘entry_id’s’ of the items I am selecting into the exp_weblog_data field. This is all fine. What I need to be able to do is to use a PHP MySQL query (not within EE) so that I can make the PHP file as a totally standalone file which is what I need for what I am doing.
The data inside the field that your extension is inputting is like this :
102
104
105
106
112
etc..
Your extension is putting in the entry_id’s with a return / newline between them. What I need to be able to do is to bring back these numbers which I can do with a simple SELECT query but then I need to be able to perform queries using each of the entry_id’s contained in that field. So for example I would first of all bring back the field contents as above and then I would like to be able to explode (I think that’s the correct term) each of these numbers so that they can each be used in a SQL query to spit out another answer.
So for example :
SELECT field_id_44 FROM exp_weblog_data WHERE entry_id = '3'
This will bring back
102 104 105 106 112
I would then like to be able to run another SQL query multiple times using each of the numbers in it. So :
SELECT field_id_46 FROM exp_weblog_data WHERE entry_id = '102' AND weblog_id = '7'
Next run the same query on the next number
SELECT field_id_46 FROM exp_weblog_data WHERE entry_id = '104' AND weblog_id = '7'
I can then spit out data each time to do what I need to do.
The part I am having problems with is getting the data that is in the multi drop down field and exploding it into its separate number parts.
If anyone understands any of this and could possibly lend a hand with this then I would be exceptionally grateful.
Yup. I’ve done this several times and here’s what I’ve found to be the most effective. First return your data in the parent entry, so like you have something like this:
SELECT field_id_46 FROM exp_weblog_data WHERE entry_id = '102' AND weblog_id = '7'
Then using PHP split that data into an array. To do this there are several methods, personally I like to use preg_split (but i’m sure explode() and split() would also work) and split on both newlines and carriage returns. I split on both (even though the extension uses only carriage returns) just in case someone uses phpMyAdmin to edit the MySQL, since it seems to use newlines not carriage returns. So that said, our code now looks something like this:
$query = mysql_query("SELECT field_id_46 AS children FROM exp_weblog_data WHERE entry_id=102 AND weblog_id=7"); $result = mysql_fetch_object($query); $children = preg_split("/[\r\n]/+", $result->children);
Now we have our children entries in an array and we can simply place them back in another MySQL query like so:
$query = mysql_query("SELECT entry_title FROM exp_weblog_titles WHERE entry_id IN(".implode(",", $children).")");
Using that you can loop through all your returned results. I’ve compiled this below:
$query = mysql_query("SELECT field_id_46 AS children FROM exp_weblog_data WHERE entry_id=102 AND weblog_id=7"); $result = mysql_fetch_object($query); $children = preg_split("/[\r\n]/+", $result->children); $query = mysql_query("SELECT url_title, title FROM exp_weblog_titles WHERE entry_id IN(".implode(",", $children).")"); while($result = mysql_fetch_object($query)) { // -- Individual entry processing here. Something like: // -- echo '<li><a href="/article/'.$result->url_title.'" title="'.$result->title.'">'.$result->title.'</a></li>'; }
Haven’t had chance to try out your code yet as I did actually get it all working in the end but using a whole heap more code than yours!!
Was just about to post here and then I saw this. Will give it a go as soon as I get the chance. If it works the way I need it to, which I’m sure that it will then you will save me quite a few lines of code!!
Thanks for everything. Please let me know if there is ever anything I can do to help you out in any way at all.