Hello and thanks for the sweet words.
Almost perfect timing; we are working on an update which adds a lot of flexibility to the row/column templates.
I’m already testing the new version, and I hope tomorrow we push it on wordpress.org
Also, in the new version, there is a filter which allows you to skip the Gridable style https://github.com/pixelgrade/gridable/tree/dev#remove-gridable-style
Thanks again for your support and I promise I will get back after we update the plugin.
Thanks for the update! I managed to dequeue the standard Gridable stylesheet and change the row class.
However, changing the column class seems a little bit more complicated.
I would like to change gridable--col hand-span-3
to simply col-md-3
.
I tried the gridable_sh_col_classes
filter, but the available $size
seems to contain not the integer, but an array.
So this won’t work:
add_filter( 'gridable_sh_col_classes', 'custom_gridable_classes' );
function custom_gridable_classes( $size ) {
$classes = array( 'col-md-', $size );
return $classes;
}
Instead this will work:
add_filter( 'gridable_sh_col_classes', 'custom_gridable_classes' );
function custom_gridable_classes( $sizes ) {
// Implode array.
$size = implode( '', $sizes );
// Remove all non-numeric characters, so that we get the size of the column as integer.
$size = preg_replace( '/[^0-9]/', '', $size );
// Save the only class as array.
$classes = array( 'col-md-' . $size );
// Return the array.
return $classes;
}
Looks dirty 🙁
I wish we could change the class names of columns with a simple string (or an array, like in my first example).
Thanks anyway!
-
This reply was modified 8 years, 3 months ago by
ninetienne.
-
This reply was modified 8 years, 3 months ago by
ninetienne.
Yep, you are totally right! There should be a consistency between row and column filters.
In the next update we will take the WordPress core approach like the “body_class” filter https://codex.wordpress.org/Plugin_API/Filter_Reference/body_class
Thank you for your feedback, it helps a lot!
-
This reply was modified 8 years, 3 months ago by
Andrei Lupu.
Sounds great, but the body_class
filter doesn’t pass a parameter and we need the integer of the column size, otherwise we won’t be able to change gridable--col hand-span-3
to simply col-3
.
Well, I’m not a good coder anyway 🙂
Don’t worry, you will have access to the column size as well in parameters. We just want to follow the WordPress standards on this.
Hey,
The new version is live, and there has been made some changes to the filters we discussed above.
Now the filters names are simply gridable_row_class
and gridable_column_class
.
The best part is that it supports four parameters, here is an example
function mycustom_gridable_column_class( $classes, $size, $atts, $content ) {
$classes[] = 'column col-' . $size;
return $classes;
}
add_filter( 'gridable_column_class', 'mycustom_gridable_column_class', 10, 4 );
Now the column attributes and the content are available with these filters.
This way, we could add an empty_column
class when a column is empty. This way we can hide it on mobile devices.
Thanks
This is great. You’re awesome. I’ll give it a shot, when I have some free time and post back. Thank you very much!