Set up the PodsUI class object.
Easily create content admin screens with in-depth customization. This is the primary interface function that Pods runs off of. It’s also the only function required to be run in order to have a fully functional Manage interface.
Please note: The options listed here are still undergoing cleanup from our old Pods 1.x documentation.
Contents
Function Definition
function pods_ui ( $obj, $deprecated = false )
Source File:/pods/includes/classes.php
Since: 2.0
Parameters
PARAMETER | TYPE | DETAILS |
---|---|---|
$obj | (array|string|Pods) | (optional) Configuration options for the UI |
$deprecated | (boolean) | (optional) Whether to enable deprecated options (used by pods_ui_manage) |
Additional Parameter Options
OPTION | TYPE | DEFAULT | DETAILS |
---|---|---|---|
pod | (string) | null | Pod to use in $object (ONLY works if passing as an array / querystring instead of an $object) |
items | (string) | Pod Type with underscores replaced as spaces and run through ucwords() | The title to show on the Manage screen: “Manage $title” |
item | (string) | Pod Type with underscores replaced as spaces and run through ucwords() | What to call this item in various messages: “Add New $item”, “$item not found, cannot delete.”, “$item not found, cannot edit.” |
num | (string) | null | If you have multiple manage interfaces intertwined, you can provide this as a unique identifier |
id | (string) | $_GET[’id’.$object->ui[’num’] | You can override the ID value here, which ignores whatever is in the URL at the time |
fields | (array) | null | Set of arrays of fields to use for manage/search/add/edit/duplicate/reorder/export |
action | (string) | $_GET[’action’.$object->ui[’num’] | You can override the action value here, which ignores whatever is in the URLat the time |
label | (array) | null | Custom label array, for add/edit/duplicate submit button text, and for add_new/reorder link text in heading |
reorder | (array) | null | Options for on/limit/orderby/orderby_dir/sql for the Reorder functionality |
orderby | (string) | t.name ASC | What column to ORDER BY, within findRecords() |
sortable | (string) | null | If this variable is defined, it will TURN OFF the ability to sort by fields in the manage screen |
limit | (integer) | 25 | How many records to show per page, within findRecords(), can be overridden by Show per page option listed next to pagination |
where | (array) | null | How to restrict the manage/reorder table list |
sql | (string) | null | You can provide an SQL statement to override the default SQL generated in findRecords() |
search | (boolean) | null | Whether or not to show the search box above the Manage screen when listing items. Set to ‘false’ to turn off |
search_across | (boolean) | null | Whether or not to search across all fields (excluding pick fields, which you can enable in ‘search_across_picks’). Set to ‘false’ to turn off |
search_across_picks | (boolean) | null | Whether or not to search across all pick fields. Set to ‘true’ to turn on |
filters | (array) | null | Additional filters to show for a Pod in Search area |
custom_filters | (string) | null | Custom HTML to appear in the Search Area (before Filters and Search box) |
actions_disabled | (array) | null | An array of actions to disable, if you supply ‘add’ and/or ‘edit’ it will also disable the link on the Manage screens |
actions_hidden | (array) | null | An array of actions to hide, if you supply ‘add’ and/or ‘edit’ it will also hide the link on the Manage screens |
actions_custom | (array) | array() | An array of custom actions and corresponding functions to run, they will appear under Pod Items next to Edit and Delete, label shows up with underscores replaced as spaces and run through ucwords(): $action=>$function. Example usage: actions_custom = array( ‘your_action’ => array( ‘label’ => ‘Your Action Name’, ‘callback’ => ‘your_callback_function’ ) ); |
action_after | (array) | null | Array of actions to go to after add/edit/delete, sets the action to set in the URL after saving an item (defaults to form, but you can set this to ‘manage’ to send back to the Manage panel) |
action_links | (array) | null | Array of custom links to go to for add/edit/duplicate/view/delete/reorder instead of the defaults |
wpcss | (string) | null | If this variable is defined (even if defined as 0), Pods UI will output the required CSS to make the UI output look like WP – BE SURE TO HAVE “!important” IN YOUR CSS OR THIS WILL OVERRIDE YOUR PREVIOUSLY DECLARED CSS STYLES |
Returns
(PodsUI) The PodsUI object.
Examples
Example 1
Pass an array to pods_ui() with the name of the Pod in the ‘pod’ key.
<?php $ui = array( 'pod' => 'your_pod', 'title' => 'My Pod', 'add_fields' => array( 'name', 'body' ), 'edit_fields' => array( 'name', 'body', 'approved' ) ); pods_ui( $ui );
Example 2
Pass an array to pods_ui() with a Pods object as the ‘pod’ key.
<?php $object = pods( 'yourpod' ); $ui = array( 'pod' => $object; 'title' => 'My Pod', 'add_fields' => array( 'name', 'body' ), 'edit_fields' => array( 'name', 'body', 'approved' ) ); pods_ui( $ui );
Example 3
Pass a Pods object to pods_ui(); you can set the Pods->ui array directly on the Pods object.
<?php $object = pods( 'yourpod' ); $object->ui = array( 'title' => 'My Pod', 'add_fields' => array( 'name', 'body' ), 'edit_fields' => array( 'name', 'body', 'approved' ) ); pods_ui( $object );
Customizing the fields on various content management screens
Programmatically exclude or customize the fields listed on the add, edit, and manage ui screens (Thanks to Kamil Grzegorczyk for this practical example and the great pods_ui() reference on LOWGRAVITY.PL)
<?php $object = pods('name_of_pod'); $fields = array(); // iterate through the fields in this pod foreach($object->fields as $field => $data) { $fields[$field] = array('label' => $data['label']); } // exclude a specific field by field name unset($fields['field_name']); // customize the label for a particular field $fields['field_name'] = array( 'label' => 'some_different_label'); // hide some fields on edit screen but still have them on the add screen $edit_fields = $fields; unset($edit_fields['field_name']); // fields visible on manage screens $manage_fields = array('few', 'manage', 'fields'); $object->ui = array( 'fields' => array( 'add' => $fields, 'edit' => $edit_fields, 'manage' => $manage_fields, ), //other parameters ); pods_ui($object);
Parameters deprecated in 2.x
- title
- label
- label_add
- label_edit
- label_duplicated
- columns
- reorder_columns
- add_fields
- edit_fields
- duplicate_fields
- session_filters
- user_per_page
- user_sort
- custom_list
- custom_reorder
- custom_add
- custom_edit
- custom_duplicate
- custom_delete
- custom_save
- custom_actions
- edit_link
- view_link
- duplicate_link
- reorder
- reorder_sort
- reorder_limit
- reorder_sql
- sort
- edit_where
- duplicate_where
- delete_where
- reorder_where
- search
- disable_actions
- hide_actions