Make it possible to get parameters passed to a wpDataTable and update a Placeholder value with the parameter passed:
URL Example:
www.abc.com/?param1=abc
wpDataTable placehholder:
%var1% = param1
Hello Rudi,
Thank you for your suggestion. Could you provide a more precise explanation so that we can have clearer information for our future development? Currently, we have an option to use URL parameters for filtering, as shown in this link (Advanced filtering). Maybe this could help you for now.
Hi Stefan,
I’m familiar with URL filtering. This essentially return the whole table with a ‘filter’, but if the filter is removed the whole table is accessible.
What I’m suggesting is to allow PLACEHOLDERS to reference parameter names passed in URL’s. This will make it possible to make dynamic tables which are prefiltered record sets based on a hard Placeholder filter.
Example:
Currently:
My suggestion:
Placeholder %VAR1% = “param1”
As a novice user I’m just commenting that this is an interesting suggestion and I can also see some use scenarios for this.
I’m wondering though what should happen if the parameter (and variable) is omitted from the URL. There is a way to set a default fallback value or the whole table is accessible again..? Although I don’t know if this is a problem or not, depends on the scenario of the original suggestion.
I have a table with over 3 million rows representing residuals from movies or TV of which only handful need to be accessed for any particular product (movie) in a tab for that product. I would prefer not to load all 3 million records with “pre-filtering” and I have to hide the column with css that the filter is based on. Currently, I plan to use the filter wpdatatables_filter_mysql_query to perform the filtering, but it would be better to have the feature suggested in this thread.
The solution with wpdatabases_filter_mysql_query does not work.
However another solution is to create your own short code that builds the wpDataTables shortcode dynamically with the WordPress function do_shortcode:
add_shortcode( ‘queryparamdatatable’, ‘queryparamdatatable’);
function queryparamdatatable( $atts ) $default = array(‘id’ => ‘’, ‘queryparam’ => ‘’);
$a = shortcode_atts( $default, $atts );
$id = $a[‘id’];
$param = $a[‘queryparam’];
$var1 = $_GET[$param];
$string = ‘[wpdatatable id=’.$id.’ var1=’.$var1.’]’;
error_log($string);
echo do_shortcode(‘[wpdatatable id=’.$id.’ var1=’.$var1.’]’);
}
Then use %VAR1% in SQL statement for the wpDataTable.