Skip to content

Instantly share code, notes, and snippets.

@mastef
Last active January 31, 2022 06:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mastef/c14bee693246dca79a5ccf44c5ec953f to your computer and use it in GitHub Desktop.
Save mastef/c14bee693246dca79a5ccf44c5ec953f to your computer and use it in GitHub Desktop.
Pods : How to add Custom Admin Table Columns to a Pods ACT
<?php
/*
only important name is the filter name :
pods_admin_ui_PODNAME
if your pods is called "client" then call it
pods_admin_ui_client
you can rename all functions to your liking
*/
add_filter( 'pods_admin_ui_PODNAME', 'custom_admin_table_columns_for_PODNAME' );
function custom_admin_table_columns_for_PODNAME ( $ui ) {
// Adds an admin column called "Info"
$ui['fields']['manage']['info'] = array(
'label' => 'Info',
'sortable' => false,
'custom_display' => 'admin_column_info_based_on_PODNAME_id' // function that will be called for every row
);
// Add an admin column called "Info 2"
$ui['fields']['manage']['info2'] = array(
'label' => "Info 2",
'sortable' => false,
'custom_display' => 'admin_column_info2_based_on_PODNAME_id' // function that will be called for every row
);
return $ui;
}
function admin_column_info_based_on_PODNAME_id($row) {
$results = [];
/* custom code here */
$sub = pods( 'other_pod' )->find( null, 1, "some_relationship_id.id='".$row["id"]."'" );
while ( $sub->fetch() ) {
$results[] = $sub->field("name");
}
/* return valid html */
return implode("<br />", $results);
}
function admin_column_info2_based_on_PODNAME_id($row) {
return $row['id'] . " " . $row['name'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment