pods_ui
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.
Function Definition
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
Returns
(PodsUI)
Examples
Example 1
Pass an array to pods_ui() with the name of the Pod in the 'pod' key
<?php
$ui = array(
'pod' => 'yourpod',
'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 );
Example 4
<?php
pods_ui( 'pod=yourpod&title=My%20Pod&add_fields=name,body&edit_fields=name,body,approved' );
Example 5
<?php
//so simple!
pods_ui( 'pod=yourpod&title=My%20Pod' );
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);
Additional Information
Parameters deprecated in 2.0:
- 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