Article changelog:

  • [1 nov 2012] few new parameters and comments (items, filters, orderby and other)
  • [10 dec 2012] few fixes, new additional parameters for pods framework 2.1
  • [19 jan 2013] actions_custom update
  • [3 feb 2013] where clause
  • [3 jun 2013] restrict parameter

Pods_ui is a very powerful function which is responsible for building custom admin interfaces in pods framework 2.0.

Similar to pods_ui_manage from version 1.x this function helps us in building customized interfaces which fit our needs. The problem is that the current documentation is not up to date and all of the code examples are using deprecated parameters syntax but they are not setting $deprecated to true.

Also there is no distinction between deprecated and up to date functions – which means that we cannot build code which uses newest features and is 100% compatible. That is why I have decided to write this short article to help You with this task along with few very simple examples.

This article is based on pods framework 2.1 It will be updated whenever I will use new pods_ui features

Pods framework 2.x deprecated parameters:

  • 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

Most of current pods framework 2.0  parameters

There is a lot more parameters, but they are not so commonly used and their functionality is not always implemented in 100%.  I will post updates or write new articles whenever I use more of them.

Simple example – default add / edit fields

Somebody on pods framework forums asked how we can add all add_ and edit_fields by default. Below you can find short example of how You can manage it in very easy way. I have also added few example uses cases of how You can customize it

Thank you for reading my article and if You have any questions please don’t hesitate to ask in the comments.

Related posts

Posted by Kamil Grzegorczyk Owner / Development

  • Excellent job! We’ll use some of this in our own docs area and link to your full article when we get a chance.

    • That would be great. A lot of people are still looking for working examples of 2.0 compatible code

  • Lance Butler

    A very good write-up. Not only will it open some eyes as to coding up management screens, but I like way you added all the fields and unset fields that weren’t needed for add/edit/manage screens – just another tip I’ve now picked up from randomly reading people’s blogs.

    Did you fire this code in the ‘admin_menu’ hook for WordPress? That’s the way I’ve been doing it (based on pods 1.x), and if so, this article MIGHT benefit from some BRIEF description of where to add the UI related code.

    • Thanks 🙂

      Well, I have assumed that everybody read the base tutorial about PODS UI setup.
      http://mondaybynoon.com/20100104/pods-ui-intro/

      Things didn’t changed much since that article and base setup can be exactly the same – using ‘admin_menu’ filter. I’m using almost the same approach – which gives me a possibility to mix PODS UI with my custom / wordpress functionalities.

  • Rhys Bartels-Waller

    Really keen to see an example of how to change the input type of a filter.

    http://podsframework.org/forums/topic/pods-ui-filters-how-to-display-as-a-select-element/

    Would be nice if the type of field was referenced for the default input element. i.e. if a simple list Pick field, then return all options as a select. A parameter could always override this, but it makes more sense logically that the search be restricted to what has been defined.

    Thanks

    • I will try to take a look on that while working on next article.

      • Rhys Bartels-Waller

        Thanks, much appreciated.

        • I have talked with Scott regarding filters as selectboxes for pick fields. Currently there is some bug which should be repaired in 2.0.5 version. As soon as it will work I will try to compose short tutorial about that.

    • Post is updated – You should find an answer for Your question by using filters and filters_enhanced parameter set to true.

  • PW

    Hi, how would you filter the records displayed in a pod’s input screen based on the logged in user?

    • Would You like to display different set of fields based (for example) on user capabilities?

  • PW

    I’m trying to get a subset of the records based on the logged-in user.

    findRecords(array(‘orderby’ => ‘t.name’, ‘limit’ => -1, ‘where’ => ‘author.user_login=”‘.$current_user->user_login.'”‘));
    $total_object = $object->getTotalRows();

    if($object->getTotalRows() > 0)
    {
    while ( $object->fetchRecord() )
    {
    $add_fields = $edit_fields = array(
    ‘name’,
    ‘win_id’,
    ‘sti_racf’,
    ‘sti_lan’,
    ‘sti_mframe’,
    ‘rc_user’,
    ‘rc_priv’,
    ‘trips_user’,
    ‘trips_priv’,
    ‘author’,
    ‘remove_user’,
    ‘reason’
    );

    $object->ui = array(
    ‘title’ => ‘Employees’,
    ‘columns’ => array(
    ‘name’ => ‘Name’,
    ‘win_id’ => ‘Win ID’,
    ‘sti_racf’ => ‘STI RACF’,
    ‘sti_lan’ => ‘STI lan’,
    ‘sti_mframe’ => ‘STI mframe’,
    ‘rc_user’ => ‘RC’,
    ‘rc_priv’ => ‘RC priv’,
    ‘trips_user’ => ‘TRIPS’,
    ‘trips_priv’ => ‘TRIPS priv’,
    ‘author’ => ‘Author’,
    ‘remove_user’ => ‘Remove user’,
    ‘reason’ => ‘Reason’
    ),
    ‘add_fields’ => $add_fields,
    ‘edit_fields’ => $edit_fields
    );
    pods_ui_manage($object);

    }
    }

    }

    add_action(‘admin_menu’,’pods_ui_employees’);

    ?>

  • PW

    I’m sorry, the top part of the program was cut off. This is the section before findrecords.

    <?php
    /*
    Plugin Name: Employees Pods UI
    Plugin URI: http://example.com/
    Description: Customized Pods UI
    Version: 1.0
    */

    function pods_ui_employees()
    {
    $icon = '';
    add_object_page('Employees', 'Employees', 'read', 'employees', '', $icon);
    add_submenu_page('employees', 'Employees', 'Employees', 'read', 'employees', 'employees_page');
    }

    function employees_page()
    {

    global $current_user, $user_login;

    get_currentuserinfo();
    $object = new Pod('employees');

  • Well I would approach the problem in very simple manner

    Something like:

  • Mike

    That looks like the makings of a great tutorial Kamil. I’m going to take your code above and see if I can figure out how to do something with it. I’m guessing you’d get it working in a more efficient way than I could, so I’ll check back here in case you ever decide to do a full tutorial on this idea.

    Thanks!

  • kelvin

    This tutorial is awesome. Even a 2 years Pod users like me are benefit by this great article. Well done.

  • PW

    Thanks Kamil. Your suggestion is excellent. And thanks for a very cool tutorial!

  • Great Pods 2.1 tutorial. I found it very helpful in tweaking my Pods 2.1 manage screen. The trouble I’m running into is the Pods filters object. When performing the search from the Pods manage admin screen with a filter object selected from a select box, I get a Database Error: …………….SQL……….. Response: Incorrect table name

    Any suggestions?

    • bigsmile

      I confirm, the following code:
      $object->ui = array(

      ‘filters’ => array(‘name’),
      );

      causes the following error:

      SELECT DISTINCT t.* FROM wp_pods_hosting AS t WHERE url.id = 0 ORDER BY t.name, t.id LIMIT 0, 25; Response: Unknown column ‘url.id’ in ‘where clause’

      • It looks like a podscms bug. Please try searching their official github for a solution

  • Chris

    I really appreciate you giving a great example of how to use Pods 2.0 UI. I took your example from the bottom of your post and gave it a try.

    Unfortunately, It keeps returning an error: “Error: Invalid Configuration – Missing “fields” definition.”

    I pasted my code here: http://pastebin.com/3j7vF4VU

    The problem lies with lines 16 and 17. I can’t seem to figure out how to get this working. Any advice? Thanks!

    • Hey,

      Are you sure that you are setting proper pods name on line 1?

      • Chris

        Positive. If i remove lines 16 and 17 the edit window for that Pod shows up.

        • Chris

          Do you think my dev environment being a WP Multisite install would have anything to do with it?

        • If the plugin is activated on this particular (not network activation) then I think multisite doesnt have any influence on that.

          I would try two things:
          a) please put into line 13,14 var_dump($fields) and var_dump($edit_fields) – and paste the results to pastebin – we will see what you are actually trying to do.

          b) I would not unset the name – maybe in your particular situation the name is required field which cannot be hidden.

          THose are my two quick solutions as I’m writing from the phone and cannot check them.

          • Chris

            Here’s the pastebin: http://pastebin.com/xfLXveM7

            I changed the name field to be unrequired. I also tried to moving the unset field. Still getting the error.

          • Please add one more set of fields to Your array – ‘manage’ – to pick which fields should be visible on manage screen

          • chrisspicuzza

            Looks like ‘manage’ was the answer. Kamil, I can’t thank you enough for taking the time to help me. I look forward to all your future pods 2.0 blogs.

  • In actions_bulk array, you pass ‘action_name’ => array( ‘label’ => ‘Action Label’, ‘callback’ => ‘your_function’ ) so the callback functions like a normal PHP callback (function name or class/method reference). Also, ‘delete’ will be included by default as a bulk action in 2.1.1

  • Thomas Herold

    Can you show me an example on how to create an addition ‘Duplicate’ link in the hover menu of Pods?

  • Thomas Herold

    Could you show me an example on how to add an additional field into the pod listing view?

    • Kamil Grzegorczyk

      Sorry for delayed response – you should find an example in my newest tutorial 🙂

  • Nick Hegarty

    Tip for those upgrading 1.x Pods UI code to 2.x and puzzled by why your fields[] entries are being ignored: It looks like Pods UI will use ‘deprecated’ mode if you fail to switch from the old constructor (var x = new Pods(‘mypod’);) to the new one (var x = pods(‘mypod’)). For some reason, in deprecated mode, it ignores the ‘fields’ array in favor of the old add_fields, edit_fields, etc. Switching over to the new constructor (not really a constructor, but whatever) fixes the issue.

    • Kamil Grzegorczyk

      Thanks for the info 🙂

  • Hi … thanks for this great tutorial .. pods is really great but it lacks documentation, so your effort is really appreciated.

    I’ve got a problem with “relationship” field type ( simple custom defined list) in pods_ui; i can correctly define this kind of field in the “manage_fields_array”, and it shows up in the manage page, but:

    – when i click on the column title (to reorder the list) a sql error shows up: Unknown column ‘t.field_name’ in ‘order clause’. It only happens for this kind of field, others are working properly (text_field, date_fields, other kind of relationship fields etc etc)

    – in the simple custom defined list (value|label), if I use “0” for the vale, i can’t see the traslation in the manage view (only the code) … it’s like the “0” code can’t be used …

    thanks for your help
    Paolo

    • If you have bugs to report, report them at http://pods.io/submit/

      Have you tested your issues here with Pods 2.3 yet? http://pods.io/latest/ it’s about to go out this week and if there’s a bug you’re still seeing in 2.3 then I’d like to get that fixed and included asap.

      • thanks mr Clark for you quick reply.
        i’m using pods 2.2, i’m going to try my issue with 2.3

        thanks again for your great piece of software!
        Paolo

      • i’ve uploaded the latest commit on my server and the problem is still there … i’ll report it as a bug.

      • this is the issue on github, thanks. https://github.com/pods-framework/pods/issues/1201

      • sorry for bothering you again! … in pods 2.3 is it possible to group fields in the edit/add screen. I’ve tried the “pods_meta_groups” action and it’s working fine, but not for the page generated by pods_ui, only in the edit default screen.

        • Pods does not currently allow groups in PodsUI, it’s only available for core WP screens themselves. This is something we’re working on, but it didn’t quite make it into Pods 2.3

          • ok, so what kind of solution can I adopt to have custom edit/add screen? available solutions, imo, are:
            1) using “$add_fields_array” and “$edit_fields_array” (see this tutorial) to customize wich fields and in wich order …
            2) using “actions_custom” parameter to define a function to show the edit page …
            3) using “action_links” parameter to override the link for edit/add, and redirect the user to the classical WP edit/screen …

            Wich is, in your opinion, the best strategy? may i have a working example?

            thanks for you time,
            Paolo

          • Kamil Grzegorczyk

            Well in most of my plugins I’m always going with option 1. This gives you the biggest control over your plugins’ UI.

            Please check my other tutorials for examples.

  • hi … can i have more informations about the “actions_custom” parameter? I’m interested in modifying the edit screen.
    Can i have an example on how to create a function to customize the edit screen, i coudn’t find any documentation on it and bypass pods UI to create a custom edit screen …

    thanks a lot,
    Paolo

    • Kamil Grzegorczyk

      Hey,

      I’ve didn’t used actions_custom in my projects yet so I cannot tell much about them. Soon the pods 2.3 will be online and then I’m planning to write new tutorial so I will try to cover actions_custom too.

  • gigi

    I’m so sorry, and I am ashamed of this… but….

    i can’t understand… where i have to put this code when i customize for my goal..

    i explain my goal if you want to help me more in detail:

    in
    WP backEnd i want that all user can see “mypod” dashboard option, but
    when users list see the pod list, i want that can see, only the pod
    created by them (these pods that they have created.. they’re the author
    of..)

    Thanks a lot for this tutorial..!!!

    • Kamil Grzegorczyk

      If you are asking about where to put the code from this tutorial then the answer is simple – it might go to your functions.php in theme or to any custom plugin you build.

      Regarding the second queston the answer is not so simple, I’ve didn’t tried to achieve this in recent version of pods but I would hook into “where” parameter for all the UI screens.

      If you would iike me to develop such functionality for you, please use a contact form at the contact page and we can discuss the details.

      • gigi

        The second one isn’t a question, but i thought it can help you to understand my first question…
        beacuse i originally thought that the code you write, can be placed in different places depending on the particular goal….

        Now…
        Talking about the code in the article..

        i have a pod named “azienda” that have some fields named “mail” and “attivo”.
        i try to put this code..

        http://pastebin.com/qxZ6DRas

        …in function.php in my theme,
        but nothing change neither in manage or in add view for the pod… 🙁

        • Kamil Grzegorczyk

          this tutorial might explain you better how to implement that
          http://lowgravity.pl/blog/introduction-to-podsframework-2-x-part-4-simple-plugin/

          unfortunately you cannot just drop in this code in functions php, you have to hook it to correct action

          • gigi

            mmh…

            this tutorial is about creating a new plugin… i don’t need it…
            i can put it in function.php…… if i know how.. 🙁

          • Kamil Grzegorczyk

            If you drop it to functions.php it will work too 😉

            Of course I would not advice putting a lot of functionalities into theme but if you just want to make it work then it will work in your theme’s functions.php

          • gigi

            It’s great… it WORKS (almost)..

            I use your code (http://lowgravity.pl/blog/introduction-to-podsframework-2-x-part-4-simple-plugin/)
            and add my pods management.

            The only problem is that only the Admin can see the plugin…
            i search in WP codex and “admin_menu” should be visibile to every users…

            Am I wrong..!?
            There something that i miss…?!?!

          • Kamil Grzegorczyk

            yes – my example uses “manage_options” capability (which should mean “admin” on default install) , you can use any different one which fits your needs 🙂

            http://codex.wordpress.org/Roles_and_Capabilities

          • gigi

            Yeeeeeeaaaaaahhhh…!!!!!

            i thank you on your knees…..A LOT..!!

            i write here [http://pastebin.com/hJP8b7Hq]
            my code in case someone has the same problem..

            Thanks again..!!
            (i hope this thread can be useful for someone else)

          • gigi

            Again ME 🙂 ….

            my code works for the manage screen where i list all the pods (filtered with where clause)…

            but in edit screen it seems don’t work, and seems ignore the where clause, because i can see all the pods navigating with previous and next link (you can see them in the piucture [http://imgur.com/zcYrXGT] ).

            i thought that adding where for all the keys…

            $where = (where cluase)

            ‘where’ => array(
            ‘manage’ => $where,
            ‘edit’ => $where,
            ‘duplicate’ => $where,
            ‘delete’ => $where,
            ‘reorder’ => $where
            )

            … (over all the “edit”) i can see only pods in where clause, but it is not so…. 🙁

            can you say something about this..?!?

          • Kamil Grzegorczyk

            maybe thats a bug, please ask about it in the pods forums.

          • gigi

            if someone is interested about the “bug” above,
            here the post where i ask about it in pods forum…

            [https://github.com/pods-framework/pods/issues/1441#issuecomment-18786012]

            Thanks again..

          • Kamil Grzegorczyk

            Great that you have solved your issue.

            Tutorial is updated now with new parameters

  • MIchael Patek

    thanks for the documentation, this is very useful. i can’t seem to get the filter/search persistence working (w/ either ‘user’ or ‘session’). have you been able to use this feature successfully? anything that i might be forgetting? thanks.

    • Kamil Grzegorczyk

      Hello,
      I never had a chance to use that feature.

      Currently I wasn’t tracking pods since 2.3 because I’m working on different projects and I’m not sure if this functionality is fully supported at the moment.

      In the current documentation I found something like this:
      session_filters(boolean)nullSet to false to disable Session-based Persistence for Searching and Filtering

  • seven24

    I’d like to be able to call custom shortcodes in Pods Templates. So far, it doesn’t seem possible. Any suggestions?

    • add_filter( ‘pods_templates_post_template’, ‘do_shortcode’ );

      • Awesome, Scott. Thank you!

        Is it possible to have a header and footer in the template so I can enclose the content that needs to loop inside it? e.g. [accordion] would be the header, [/accordion] would be the footer.

        [accordion]

        [toggle title="[email protected]_title}"]
        [email protected]_content}
        [/toggle]

        [/accordion]

        • You can create your own shortcodes and do whatever you’d like there. I’m not entirely sure what you mean though.

  • seifallah

    How can I limit the item visible in the screen ? i.e. $object = pods(‘name_of_pod’, $id_or_slug);
    I already tried this but it shows to me all the items in the selected pod

    Thank you

Like what you see?

Contact us today and get started!