Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Drew

Support for filterable custom columns

Hi there, I implemented filterable custom columns today with admin columns. I thought it would be supported by default, but I can see after looking at the code why it’s not. That said, I believe the way I supported it is extensible and generally in line with the style I saw in your plugin.

Could support for this feature be added?

I updated CAC_Filtering_Model_Post this way:

// in enable_filtering, added include type filter

$include_types = apply_filters( 'cac/addon/filtering/include_types', $include_types );

// in handle_filter_requests added default case to switch

default:
if(method_exists($column, ‘posts_where_for_custom_column’)){
add_filter(‘posts_where’, array($column, ‘posts_where_for_custom_column’));
}
break;



// in add_filtering_dropdown added default case to switch

default:
if(method_exists($column, ‘distinct_column_values’)){
$distinctVals = $column->distinct_column_values();
$options = array_combine($distinctVals,$distinctVals);
}
break;
`

9 years, 11 months ago
Drew

With the code pasted correctly

// in enable_filtering, added include type filter

$include_types = apply_filters( 'cac/addon/filtering/include_types', $include_types );

// in handle_filter_requests added default case to switch
default:
if(method_exists($column, ‘posts_where_for_custom_column’)){
add_filter(‘posts_where’, array($column, ‘posts_where_for_custom_column’));
}
break;

// in add_filtering_dropdown added default case to switch
default:
if(method_exists($column, ‘distinct_column_values’)){
$distinctVals = $column->distinct_column_values();
$options = array_combine($distinctVals,$distinctVals);
}
break;
9 years, 11 months ago
Jesper

Hi Drew,

Thanks for your suggestion! I do agree that at this point, the filtering functionality from Admin Columns Pro is not directly extensible.

We’ll look into possibilities for extending filtering to custom column types more easily. The implementation you supply for enabling filtering for columns looks quite elegant, and we will probably use it as the basis for our implementation. However, we’re likely to add more functionality via filtering (instead of using additional column methods).

Thanks a lot for your suggestion, we certainly appreciate developers pitching in!

With kind regards,
Jesper

9 years, 11 months ago
Timothy

I agree with the filtering improvement. I expected several of the default columns to be out of the box filtering like author etc…

9 years, 10 months ago
Jesper

At this point, default columns are, indeed, not filterable. However, most default columns, such as the author, categories and tags columns, can be replicated by using the “Display Author As” and “Taxonomy” columns, respectively. These columns offer more options, and even better, they’re filterable!

9 years, 10 months ago

You must be logged in to reply to this topic.