• Resolved ninetienne

    (@ninetienne)


    Thanks again for the awesome plugin.

    Could you please tell me, what filters I should use to override the Gridable classes?

    I have Bootstrap in my theme and hence would like to change classes to col-md-4 for example.

    I would also highly appreciate if you could tell me how to properly dequeue the Gridable stylesheet.

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Andrei Lupu

    (@euthelup)

    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 www.ads-software.com

    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.

    Thread Starter ninetienne

    (@ninetienne)

    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, 1 month ago by ninetienne.
    • This reply was modified 8 years, 1 month ago by ninetienne.
    Plugin Contributor Andrei Lupu

    (@euthelup)

    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.www.ads-software.com/Plugin_API/Filter_Reference/body_class

    Thank you for your feedback, it helps a lot!

    • This reply was modified 8 years, 1 month ago by Andrei Lupu.
    Thread Starter ninetienne

    (@ninetienne)

    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 ??

    Plugin Contributor Andrei Lupu

    (@euthelup)

    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.

    Thread Starter ninetienne

    (@ninetienne)

    Sounds great!

    Thanks a lot ??

    Plugin Contributor Andrei Lupu

    (@euthelup)

    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

    Thread Starter ninetienne

    (@ninetienne)

    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!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Filters’ is closed to new replies.