option-tree icon indicating copy to clipboard operation
option-tree copied to clipboard

Feature request: Extended custom post type select

Open sparkdevelopment opened this issue 11 years ago • 10 comments

Sorry to keep adding to the issues, but I've come across an issue with the custom_post_type_select, not because of the code but because it produces such a long list it becomes unwieldy. Is it possible to have a field with two selects, the first being either the post type or the first letter, and the second being the filtered results based on the selection of the first.

Thanks!

sparkdevelopment avatar Jan 29 '14 12:01 sparkdevelopment

Sorry, but that would alter the current functionality of the option type and would likely be to specific for the majority of use cases. I suggest creating your own option type based off of the custom_post_type_select. Copy the ot_type_custom_post_type_select() function to your functions.php and either rename it (ot_type_ must stay at the beginning) or leave it the same name to overload the current option type for your theme and make the necessary adjustments. Once you've got a proof of concept I'm more than happy to merge it into the codebase if it looks like something we could all benefit from. If you get stuck feel free to ask questions. Cheers!

valendesigns avatar Jan 31 '14 02:01 valendesigns

Thanks - I'll work on it.

sparkdevelopment avatar Jan 31 '14 08:01 sparkdevelopment

Hey Derek, has anyone else noticed the width of the Select? I noticed it was going off the panel and over the description. Not sure if anyone has mentioned this. I added a max-width to line 2121 in the ot-admin.css just in case anyone else runs into the same issue.

StefsterNYC avatar May 17 '14 14:05 StefsterNYC

@sparkdevelopment @valendesigns What could be interesting, instead of having two selects, is to make the select fields searchable/filterable! Not only this would be great for ALL current select options (Posts, Pages, CPT, etc.) but it's also SUPER EASY to implement!

Just add the Chosen jQuery plugin to OptionTree and make all select fields searchable/filterable: http://harvesthq.github.io/chosen/

chosen a jquery plugin by harvest to tame unwieldy select boxes

To convert any select in OptionTree to the above image, just enqueue the Chosen javascript file, and then in ot-admin.js add the following:

$(".option-tree-ui-select").chosen({disable_search_threshold: 10});

In addition to this - but this could go into another issue - it would improve the searching/filtering experience if we display more information than the post Title for the Posts, Pages and CPT options types. What I mean is that two posts can have the same title, so it gets confusing. What I suggest is to display also the post ID in addition to the post Title, for example: "Title (ID)" rather than just "Title" as it currently is. If using the Chosen jQuery plugin, the user could enter any post ID to find the matching post and select it very easily.


@StefsterNYC You should probably open a separate issue as this one is not really related to your issue. Having said that, I didn't experience that so perhaps there're conflicting CSS with another plugins you're using? You can right-click on the select and click "Inspect" in Chrome or Firefox and see what CSS rule is making it so long. Maybe you could post a screenshot with the console open, that would eventually help determine the cause :)

bitcommit avatar May 17 '14 17:05 bitcommit

Oh sorry. I didn't have an issue. Just pointed out what I saw. That's all. 

Thanks

StefsterNYC avatar May 17 '14 18:05 StefsterNYC

@StefsterNYC Could it be because one of your options in the select field is too long? Usually a select field adapts to the largest contained option. I insist that this definitely deserves a separate issue as this bug is not related with the current issue at all, and still needs fixing so I've opened a new issue based on your feedback: https://github.com/valendesigns/option-tree/issues/333 Thank you!

bitcommit avatar May 18 '14 03:05 bitcommit

Even if it was that it still would require a fix. But yes, you could be right about that if a category or post name was long it would stretch it.

StefsterNYC avatar May 18 '14 03:05 StefsterNYC

@bitcommit I would love to extend the select by adding the chosen plugin, but it's not responsive and will inevitably break the UI. Are there any responsive options out there?

valendesigns avatar May 31 '14 11:05 valendesigns

What about http://ivaynberg.github.io/select2/

Looks like it is responsive too and has a lot of features, even remote data search.

doitmax avatar Jun 06 '14 19:06 doitmax

@doitmax That looks promising.

valendesigns avatar Jun 06 '14 20:06 valendesigns