Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Field column classes #68

Open
JiveDig opened this issue Oct 30, 2014 · 25 comments
Open

Feature Request - Field column classes #68

JiveDig opened this issue Oct 30, 2014 · 25 comments

Comments

@JiveDig
Copy link

JiveDig commented Oct 30, 2014

Human Made's fork does something similar but i don't like the approach as much.

I used before_row and after_row to wrap my field in <div class="prefix-one-half"> in order to add different amounts of columns via CSS. I used the CSS from Genesis/Bootstrap for the columns. It works and looks great BUT it adds a wrap around the cmb-row. That causes problems when i need to target all rows via CSS.

It would be great to have an attribute for:
columns -> 'one-half first' and columns -> 'one-half'

The same way Genesis does it. The one-half.first clears the float and removes the left margin.

This setting would add the classes right inside the cmb-row div.. for consistency.
The output would be:

<div class="cmb-row cmb-one-half cmb-first">

Columns would be all the bootstrap/G stuff... one-half one-third one-fourth, two-thirds, etc... Not much CSS involved, it's just getting the attribute/parameter setup.

@mathetos
Copy link

mathetos commented Feb 9, 2015

This was one of the reasons I switched to Human Made's fork before CMB2 rolled around. Would love to see this implemented. I'd assume though that it would apply exclusively to "Grouped" fields since without a groups such columns could produce strange results.

That's a nice idea for a workaround though. Will be testing that out a bit.

@jtsternberg
Copy link
Member

There is a filter for the field row classes, cmb2_row_classes. I think that would probably be sufficient for adding the column classes for a proof of concept, right? I'd consider adding this feature, but we'd need to figure out which contexts it would make sense to apply the column styling. I don't think it would be a good fit for a user profile page, for instance. Bottom line, it's not as simple as it may seem, and would need some major testing.

@JiveDig
Copy link
Author

JiveDig commented Feb 9, 2015

Since CMB is so dev friendly... would it make more sense to just and a field attribute for class? Then we can add whatever class we want to whatever field we want. More flexible and less room for error?

Similar to what ACF just added to Pro.
screen shot 2015-02-09 at 10 36 49 am

@JiveDig
Copy link
Author

JiveDig commented Feb 9, 2015

Btw.. here's an example of what we are doing in our soon-to-be-released recipe plugin that uses CMB2. Without columns, the layout would get out of control.
screen shot 2015-02-09 at 10 34 19 am

@jtsternberg
Copy link
Member

I've added a row_classes parameter, and you can see it/use it in trunk. changelog

@JiveDig
Copy link
Author

JiveDig commented Feb 9, 2015

This is awesome! Extremely useful IMO. Thanks!

@mathetos
Copy link

mathetos commented Feb 9, 2015

Nice. That will already be a big benefit, and I agree with @JiveDig, the whole tool is targeted toward developers, if we break stuff while building we'll figure it out, this addition just gives us more flexibility to build better. Thanks!

@DevinWalker
Copy link
Contributor

Great addition. Some field sets can just get too long....

@jtsternberg
Copy link
Member

If you guys can build a solid proof of concept for making this work w/ columns, then we can get closer to getting into core.

@jtsternberg
Copy link
Member

@DevinWalker if you're referring to the unwieldy nature of the metabox config arrays, one of the goals for a future update is to convert that array to using at least a few helper functions. No matter what though, config can get large/crazy depending on what you're trying to do.

@JiveDig
Copy link
Author

JiveDig commented Feb 9, 2015

@jtsternberg proof of concept more then my recipe plugin screenshot? I'm going to convert our row wraps to this method this week... but it will look the same

@jtsternberg
Copy link
Member

@JiveDig yah, proof of concept like make a library (something like https://github.com/WebDevStudios/cmb2-attached-posts) that allows others to do the same, then test it in other scenarios like user profile pages, admin settings pages, front-end forms, etc. Make sense? Or a pull request, but that's harder to get a lot of people using/testing. Basically a workflow similar to WordPress' features-as-plugins concept.

@DevinWalker
Copy link
Contributor

@jtsternberg no I'm referring to the ability to add columns like the screenshot. I'm fine with the long arrays in the code.

@jtsternberg
Copy link
Member

@DevinWalker ah, makes sense! I bet you and @JiveDig could come up w/ a killer proof of concept. ;)

@JiveDig
Copy link
Author

JiveDig commented Feb 9, 2015

Okay, just to clarify... the row_classes parameter making it into core, right? Just nothing to do with columns at the moment?

@jtsternberg
Copy link
Member

@JiveDig that's correct. It's in core now (in trunk) and will be rolled into the next release.

pluginmirror-worker pushed a commit to wp-plugins/cmb2 that referenced this issue Feb 15, 2015
### Enhancements

* Use the more appropriate `add_meta_boxes` hook for hooking in metaboxes to post-edit screen. Thanks [@inspiraaz](https://github.com/inspiraaz) for reporting. ([#161](CMB2/CMB2#161))
* Add a `row_classes` field param which allows you to add additional classes to the cmb-row wrap. This parameter can take a string, or array, or can take a callback that returns a string or array. The callback will receive `$field_args` as the first argument, and the CMB2_Field `$field` object as the second argument. Reported/requested in [#68](CMB2/CMB2#68).
* New constant, `CMB2_LOADED`, which you can use to check if CMB2 is loaded for your plugins/themes with CMB2 dependency.
* New hooks, [`cmb2_init_before_hookup` and `cmb2_after_init`](https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/filters-and-actions).
* New API for adding metaboxes and fields, demonstrated in [`example-functions.php`](https://github.com/WebDevStudios/CMB2/blob/master/example-functions.php). In keeping with backwards-compatibility, the `cmb2_meta_boxes` filter method will still work, but is not recommended. New API includes `new_cmb2_box` helper function to generate a new metabox, and returns a `$cmb` object to add new fields (via the `CMB2::add_field()` and `CMB2::add_group_field()` methods).
* New CMB2 method, [`CMB2::remove_field()`](https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/filters-and-actions/cmb2_init_%24cmb_id-remove-field.php).
* New CMB2_Boxes method, [`CMB2_Boxes::remove()`](https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/filters-and-actions/cmb2_init_before_hookup-remove-cmb2-metabox.php).
* When clicking on a file/image in the `file`, or `file_list` type, the media modal will open with that image selected. Props [johnsonpaul1014](https://github.com/johnsonpaul1014), ([#120](CMB2/CMB2#120)).

git-svn-id: https://plugins.svn.wordpress.org/cmb2/trunk@1090772 b8457f37-d9ea-0310-8a92-e5e31aec5664
@pablo-sg-pacheco
Copy link

I've made a CMB2 plugin for that:
https://github.com/origgami/CMB2-grid

CMB2 Grid - A grid system for Wordpress CMB2 library that allows the creation of columns for a better layout in the admin

I hope you guys enjoy it and give me a feedback

@DevinWalker
Copy link
Contributor

Pretty cool work @Pablo-Pacheco - combine that with the ability to add tabs then it's really taking it to the next level.

@pablo-sg-pacheco
Copy link

Thank you :)

It's a good idea

@paaljoachim
Copy link

I happen to come across this thread. What about integrating CMB2 grid directly into the CMB2 core?
(Since this thread is a bit old right now perhaps CMB2 already has something very similar integrated.)

@bentalgad
Copy link

I think this one is a must!

@Mte90
Copy link
Contributor

Mte90 commented Mar 3, 2017

I am using cmb2-grid but integrated will be the best solution!

@jtsternberg jtsternberg added the UI label Mar 6, 2017
@carl-alberto
Copy link

+1 in seeing the cmb2-grid integrated!

@andrastudio
Copy link

Is it integrated yet?

@Mte90
Copy link
Contributor

Mte90 commented May 13, 2020

no

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants