Add additional option to custom CMS dropdown

10 posts by 2 authors in: Forums > CMS Builder
Last Post: January 29, 2015   (RSS)

By nmsinc - January 29, 2015

I’m using the custom code below to create a dropdown of records within the CMS. I also need to add an additional option after the records populate in the dropdown. This option will be labled “Other” and I’m not sure how to do this.

Please note that this additional option cannot be a record in the section and this is why I have not added it directly!

Any help would be appreciated – thanks nmsinc

<?php
$where = "";
$where = "WHERE company = '".$CURRENT_USER['member']."' AND discontinue = '0'";
?>
SELECT num, title
FROM `<?php
echo $TABLE_PREFIX ?>types`
<?php echo $where; ?>
ORDER BY title 

nmsinc

By claire - January 29, 2015

Hey there - just to confirm, you can't just add another text field or something similar after this dropdown?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - January 29, 2015

HI Claire,

That's correct - I can't add it as a record!

Thanks - nmsinc

nmsinc

By claire - January 29, 2015

Hmm, okay. How do you want it to look on the CMS editing screen?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - January 29, 2015

The option should be the last option in the dropdown!

Thanks - nmsinc

nmsinc

By claire - January 29, 2015

Okay, this is a bit of a hack, but it might work.

Add a type to your types section called Other, then use the code below:

<?php
$where = "";
$where = "WHERE (company = '".$CURRENT_USER['member']."' AND discontinue = '0') OR title = 'Other'";
?>
SELECT num, title
FROM `<?php
echo $TABLE_PREFIX ?>types`
<?php echo $where; ?>
ORDER BY dragSortOrder, title 

This will get it into the dropdown regardless of the selection, and it assumes that you have a drag sort order on the types section. The ordering may still not work though, you might have to play around with it.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By claire - January 29, 2015

Okay, if I understand this right - you need the "Other" selection in the dropdown to reveal a text field in the record?

You may be able to do a show/hide based on the title instead.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - January 29, 2015

You have the idea right, now how can I add the additional text option to the dropdown and capture the Text when this choice is made while keeping the other options as record number?

Thanks - nmsinc

nmsinc

By claire - January 29, 2015

I'm afraid it's not possible. The closest you'll get is to allow a text field to be revealed on selection of the "Other" option in the dropdown, and then have the text field store the text value. You can't copy the text from that field into the dropdown.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/