Support

Home Forums Event Espresso Premium Meta box dropdown

Meta box dropdown

Posted: December 3, 2013 at 5:40 pm


Tony

December 3, 2013 at 5:40 pm

I’m wondering if it is possible to create a custom meta box that has a dropdown instead of a text field? Our client has one meta box that could have many different options and we are trying to make it easy to pick a selection instead of having to remember all the terms.

If this is not possible, is there a way to add a reference box to the right of the custom meta boxes? I’d like to display in text, what all the options are so that they could possibly just copy and paste from that screen.

Thank you.


Dean

December 4, 2013 at 3:58 am

Hi Tony,

Sorry, could you explain a bit more about what you are trying to achieve here please?.


Tony

December 5, 2013 at 2:26 pm

When setting up new meta boxes within the functions file, is there a way to create a dropdown of a prepopulated list that the client could choose from. Instead of having to type in the meta key (ex. blue, red, purple, yellow, lavender, etc), there would be a dropdown box there that the client/admin could just select from.

If this is not possible, is there a way to edit that area where the meta keys are to have a “legend” of what all the available colors are? A box with information about what options are available to use instead of trying to remember all the values that could be.


Dean

December 6, 2013 at 3:36 am

I see, well in the file event-espresso/includes/admin-files/functions.php is a pluggable function called event_espresso_meta_edit()

You could copy this to the Custom Files custom_functions.php file (or create this file in the uploads/espresso directory) and edit is as needed, adding in a legend or dropdown menu.

http://codex.wordpress.org/Pluggable_Functions


Tony

December 6, 2013 at 8:55 am

Yes, I’ve done that already. I’ve added 4 new meta boxes but I cannot figure out how to make those into dropdown selections instead of just a text box. Do you have any documentation on how to go about creating those?

Thank you.


Dean

December 9, 2013 at 12:28 am

Hi Tony,

We don’t have documentation on that as it is basically HTML/PHP coding which is beyond the scope of support.

If you look at the code in that function there is already something there for a select box (dropdown box) that could potentially be reused.

If you add something like

		<li>
			<label>Key:</label>
			<select id="emeta[]" name="emeta[]">
				<option>red</option>
				<option>blue</option>
				<option>green</option>
			</select>
			<label>Value:</label><input size="20" type="text" value="" name="emetad[]" id="emetad[]">
		</li>

to around this area http://d.pr/i/5S1a (line numbers are irrelevant here) it may help you get started.

If you are still unsure, it may be a good idea to contact one of our recommended developers – https://eventespresso.com/developers/event-espresso-pros/


Tony

December 9, 2013 at 9:38 am

Thanks Dean. I’ve looked through the files but cannot seem to find the file for the “Event Meta”. Can you direct me to where that file is and can I copy this file and move it to the uploads directory?


Tony

December 9, 2013 at 12:05 pm

I found it: plugins/event-espresso/includes/admin-files/functions.php

I’ve added this to the core file. I realize an update it will overwrite that file. I ended up just putting a legend to the right of the ee meta boxes so they can just copy and paste the meta value they need. I’m thinking this will be an easier thing to implement instead of adding a custom field with a select. Once that gets lost from an update, it might be a bit trickier if it disappears from all the events.

I looked through the forums, I don’t think there is a way to customize this file within the uploads directory. Or, maybe there is?


Tony

  • Support Staff

December 10, 2013 at 4:28 am

Hi Tony,

All of the functions within that file are Pluggable meaning you can place a copy of the function within the Custom Files Add-on to override the core one.

This will then be ‘update-safe’.


Tony

December 11, 2013 at 11:50 am

Good to know. So would I create a new directory in the uploads/espresso as follows:
uploads/espresso/includes/admin-files/functions.php (just move that whole functions file over)?


Josh

  • Support Staff

December 11, 2013 at 5:02 pm

Hi Tony,

It turns out that it works differently, moving the entire file over will not work.

The pluggable function itself (not the whole file) can be copied over to /wp-content/uploads/espresso/custom_functions.php and Event Espresso will check for functions there first.


Tony

December 20, 2013 at 10:55 am

Great, thank you.

The support post ‘Meta box dropdown’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso