(Wiki página de Backend Frontend Template Pro: the WordPress Plugin Template)
Un listado paginado por consulta es posible gracias a apuntar la página a una función personalizada, y usar dentro de la función $this->display_table_query_custom() y finalmente mostrar la página con $this->admin_menu_page_display()
También es necsario usar el archivo “file” => “bft-admin-display-list-table.php”
$this->display_table_query_custom()
display_table_query_custom( $query_select_inside, $query_from_inside, $query_where_inside, $group_inside, $ids, $columns_tables_dont_search, $search_concat, $column_key, $columns_tables, $columns_labels, $column_action_add, $status_system = false, $write_log_query = false )
- $query_select_inside Parte SELECT de la consulta, sin la etiqueta SELECT
- $query_from_inside Parte FROM de la consulta, sin la etiqueta FROM
- $query_where_inside Parte WHERE de la consulta, sin la etiqueta WHERE
- $group_inside Parte GROUP BY de la consulta, sin la etiqueta FROM
- $ids Ids a buscar, los índices serán la clave de la columna Puede ser un array vacío, un array con datos manuales, o un array automático con el ids_required_get_data gracias a $this->ids_required_and_optional_check_and_get() $ids = [ “teacher_id” => “1”, ]; $ids = $this->ids_required_and_optional_check_and_get ( $ids_principal_aux_type = “principal”, $ids_require_optional_type = “both”, $read_all_get_data = false );
- $columns_tables_dont_search No buscar la cadena de búsqueda en las columnas. Los índices serán la clave de la columna $columns_tables_dont_search = [ “column_1” => “table”, “column_2” => “table”, ];
- $search_concat Array bidimensional, primera dimensión es la columna final, la segunda dimensión son las columnas del CONCAT, para buscar la cadena en columnas combinadas Ej: search_string: “Lorem Ipsum” row_1 column_1: “Lorem” row_1 column_2: “Ipsum” $search_concat = [ [ “column_1” => “table”, “column_2” => “table”, ], ];
- $column_key Columna clave de la consulta
- $columns_tables Las tablas de las columnas, con índices $columns_tables_dont_search = [ “column_1” => “table”, “column_2” => “table”, ];
- $columns_labels Las etiquetas de las columnas, con índices de las columnas $columns_labels = [ “id” => $this->__(“Nº”), “column_2” => $this->__(“Label of the column”), “column_3” => “Label without internalization”, ];
- $column_action_add Añadir o no añadir un enlace
- column_action_key: la columna clave para el enlace, false si no es necesario un link
- column_action_edit_slug: el slug de la página
- $status_system La table usa la columna $this->database_status_column_name
- $write_log_query Escribe en el log la consulta base
Un ejemplo completo de $this->display_table_query_custom() usado en una función public function manual_data_manipulation_listing_by_query_example() { global $wpdb; $this->admin_permission_check(); $language_admin = $this->language_admin_get(); $ids = array(); //Add or not add a “to go element”, inside the array: “column_action_key” with the future get data with the id, “column_action_edit_slug” the target slug for the edit action $column_action_add = [ “column_action_key” => “course_id”, //The future get data name with the id “column_action_edit_slug” => $this->admin_pages_slug_name_prefix.”_automated_data_manipulation_course”, //Target slug for the edit action ]; /* SELECT wp_bft_pro_courses.id, wp_bft_pro_courses_i18n.name_i18n AS course FROM wp_bft_pro_courses LEFT JOIN wp_bft_pro_courses_i18n ON wp_bft_pro_courses.id = wp_bft_pro_courses_i18n.course_id AND wp_bft_pro_courses_i18n.language = ‘en’; WHERE teacher_id is not null */ //SELECT part of the query, whitout the SELECT tag $query_select_inside = ” “.$wpdb->prefix.$this->plugin_slug.”_”.”courses.id, “.$wpdb->prefix.$this->plugin_slug.”_”.”courses_i18n.name_i18n AS name”; //FROM part of the query, whitout the FROM tag $query_from_inside = ” “.$wpdb->prefix.$this->plugin_slug.”_”.”courses LEFT JOIN “.$wpdb->prefix.$this->plugin_slug.”_”.”courses_i18n ON “.$wpdb->prefix.$this->plugin_slug.”_”.”courses.id = “.$wpdb->prefix.$this->plugin_slug.”_”.”courses_i18n.course_id AND “.$wpdb->prefix.$this->plugin_slug.”_”.”courses_i18n.`”.$this->database_i18n_column_language.”` = ‘$language_admin'”; //WHERE part of the query, whitout the WHERE tag $query_where_inside = ” teacher_id IS NOT NULL”; //GROUP BY part of the query, whitout the FROM tag $group_inside = “”; //Column key of the query $column_key = “id”; //The tables of the columns, with indexes of the tables $columns_tables = [ “id” => $wpdb->prefix.$this->plugin_slug.”_”.”courses”, “name” => $wpdb->prefix.$this->plugin_slug.”_”.”courses_i18n”, ]; //Don’t search the search string on this columns. The indexes will be the column key $columns_tables_dont_search = array(); //Two dimensional array, first dimension is the final colum, the second dimension are the colums of the CONCAT (“column” => “table”), for search the string on the final CONCAT data $search_concat = []; //The labels of the columns, with indexes of the columns $columns_labels = [ “id” => $this->__(“Nº”), “name” => $this->__(“Course”), ]; $status_system = false; $write_log_query = false; $args = $this->display_table_query_custom($query_select_inside, $query_from_inside, $query_where_inside, $group_inside, $ids, $columns_tables_dont_search, $search_concat, $column_key, $columns_tables, $columns_labels, $column_action_add, $status_system, $write_log_query); $args[“ids”] = $ids; $this->admin_menu_page_display($args); }

0 comentarios