-
Notifications
You must be signed in to change notification settings - Fork 0
Pods_ui()
#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.
function pods_ui ( $obj, $deprecated = false )
###Parameters
Parameter | Type | Details |
---|---|---|
$obj | array or string or Pods object | Configuration options for the UI |
$deprecated | boolean | 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) |
title | 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." |
label | string | null | Custom submit label, defaults to "Save Changes" when editing, or "Add New $item" when adding |
label_add | string | null | Custom submit label, defaults to "Add New $item" |
label_edit | string | null | Custom submit label for when editing, defaults to "Save Changes"/td> |
label_duplicate | string | null | Custom submit label for when duplicating, defaults to "Add New $item" |
icon | string | null | Custom icon URL to show on page headings |
columns | array | array('name'=>'Name','created'=>'Date Created','modified'=>'Last Modified') | What columns to show on Manage: $column_name=>$column_label (pick columns have .name appended and only show first value); Available options include 'label', 'display_helper', 'coltype' |
session_filters | boolean | null | Set to false to disable Session-based Persistence for Searching and Filtering |
user_per_page | boolean | null | Set to false to disable User-based Persistence for number of items to Show Per Page |
user_sort | boolean | null | Set to false to disable User-based Persistence for Sorting |
add_fields | array | null | What fields to show when adding a Pod Item |
edit_fields | array | null | What fields to show when editing a Pod Item |
duplicate_fields | array | null | What fields to show when duplicating a Pod Item |
custom_list | string | null | A custom function to use when listing Pod Items (bypasses the Pods UI) |
custom_reorder | string | null | A custom function to use when reordering Pod Items (bypasses the Pods UI) |
custom_add | string | null | A custom function to use when adding a Pod Item (bypasses the Pods UI) |
custom_edit | string | null | A custom function to use when editing a Pod Item (bypasses the Pods UI) |
custom_duplicate | string | null | A custom function to use when duplicating a Pod Item (bypasses the Pods UI) |
custom_delete | string | null | A custom function to use when deleting a Pod Item (bypasses the Pods UI) |
custom_save | string | null | A custom function to use when action=save in URL, useful to use when you have your own custom forms using $_POST |
custom_actions | 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 |
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 | |
action_after_save | string | null | Set 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 | string | $_GET['action'.$object->ui['num']] You can override the action value here, which ignores whatever is in the URLat the time | |
edit_link | array / string | null | Override the array that builds the edit link, you may supply a string with the name of a helper to get the array from - or give the array itself |
view_link | array / string | null | Override the link used for 'View', by default it's set to use the Pods 'detail_url' setting |
duplicate_link | array / string | null | Override the link used for 'Duplicate' |
reorder | string | null | Enable the Reordering interface by supplying the column name to be reordered (works best if it's a Number column type) |
reorder_columns | array / string | columns option | What columns to show on the Reorder page |
reorder_sort | string | t.reorder option | What column to ORDER BY, within findRecords() on Reorder page |
sort | 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 |
fields | array | (default array of Pod's fields) | |
limit | integer | 25 | How many records to show per page, within findRecords(), can be overridden by Show per page option listed next to pagination |
reorder_limit | integer | 1000 | How many records to show per page, within findRecords(), can be overridden by Show per page option listed next to pagination |
where | string | null | What column to WHERE, within findRecords() |
edit_where | array | null | You can include a key=>value array with the key being the field name, and the value being the value that must match in order for to show the Edit Form for a specific user |
duplicate_where | array | (edit_where) | You can include a key=>value array with the key being the field name, and the value being the value that must match in order for to show the Edit Form for a specific user |
delete_where | array | (edit_where) | You can include a key=>value array with the key being the field name, and the value being the value that must match in order for to show the Edit Form for a specific user |
reorder_where | string | (where) What column to WHERE, within the Reorder findRecords() | |
sql | string | null | You can provide an SQL statement to override the default SQL generated in findRecords() |
reorder_sql | string | null | You can provide an SQL statement to override the default SQL generated in Reorder 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) |
disable_actions | 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 |
hide_actions | 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 |
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 ON YOUR CSS OR THIS WILL OVERRIDE YOUR PREVIOUSLY DECLARED CSS STYLES |
###Returns
Returns the PodsUI object, but it will output the management interface prior to the return
###Example
<?php
// Example #1:
$ui = array(
'pod' => 'yourpod',
'title' => 'My Pod',
'add_fields' => array( 'name', 'body' ),
'edit_fields' => array( 'name', 'body', 'approved' )
);
pods_ui( $ui );
// Example #2:
$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:
$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: (just slightly different formatting than #1)
pods_ui( 'pod=yourpod&title=My%20Pod&add_fields=name,body&edit_fields=name,body,approved' );
// Example #5: (so simple!)
pods_ui( 'pod=yourpod&title=My%20Pod' );
###Tutorials and other Resources
Using filters to change how Form Fields appear Contributed by owi See examples and additional information about how to change Form Fields and their appearance, or customize them further.
Using Pods UI to build custom admin interfaces Contributed by owi See examples of how to use Pods UI parameters to build custom admin interfaces for managing content.
Hooking into the Save / Delete process in the Pods API Contributed by owi See examples on how to use filters and actions to hook into the Save / Delete process in Pods API.
###Available Since Version
2.0+
###Source File
pods_ui() is located in /pods/functions.php
###See Also