Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using Pods plugin (ver 2.2) to create some 'Pods' or Advanced Content Types, as they would refer to it, which are like custom post types but are actually separate from WP, blank slate, in their own tables. Each content type has at least two fields.

What I wanted to know is how do I display those field inputs in the manage page columns of those Advanced Content Types (created with the Pods interface)? By default it is only showing one column, ie. the default field.

Using manage_${post_type}_posts_columns doesn't seem to work since they're not really post types.

Further research lead me to pods_ui(), but the result is undesirable: the list is blank (pic #1) and there seems to be another Pod item(?) at the bottom (pic #2).

Effort #1

This was the code:

function pods_ui_test() {
    $object = pods('cities');
    $object->ui = array(
            'columns' => array(
                    'cities'    => 'Cities',
                    'regions'   => 'Regions'
                ),
        );

    pods_ui($object, true);
}

add_filter( 'pods_admin_ui_cities', 'pods_ui_test' );

Pic #1:

Blank list

Pic #2:

Bottom part

Anybody familiar with how Pods work?


Effort #2

@ScottKingsleyClark... I think I understand what you mean, so I gave it another shot. Here's the code:

function pods_ui_test($object) {
    $pod = $object[pod];

    // Test on TITLE
    $pod->pod_data[label] = 'XXXXX';

    // Test on UI Column
    $pod->ui = array(
            'columns' => array(
                    'city'      => 'City',
                    'region'    => 'Region'
                )
            );

    return $object;
}

add_filter( 'pods_admin_ui_cities', 'pods_ui_test' );

I tested by changing the title and the column UI to see if it has any effects at all. The former works, ie.the TITLE changed, but the column remains the same, ie. only one is showing which is the default field.

share|improve this question
1  
I'm the lead developer of Pods, I'm away from home right now but should be able to respond properly tomorrow. You are using the right hook, but it's a filter so it passes a $ui variable that you change and return, not run another pods_ui. I'll have to look through your code to provide the tweaks you'd need. –  Scott Kingsley Clark Feb 4 '13 at 4:04
    
Thanks for the quick reply. I created the pods using the pods built-in interface. So I'm actually trying to add the columns to existing pods. The code above is the only pods-related code that I have. Was I supposed to create the whole Pods programmatically instead of using the interface to have the columns showing correctly? –  gmaggio Feb 4 '13 at 6:23
    
@ScottKingsleyClark... I think I understand what you mean, so I gave it another shot. But still it doesn't work. (See updated question) –  gmaggio Feb 4 '13 at 12:39

1 Answer 1

up vote 2 down vote accepted

To customize which fields are shown in Pods UI, you can filter the default UI options through this filter / function combination. Overriding the $ui array with the options you wish to customize, this can be pretty quick and easy.

function pods_ui_test ( $ui ) {
    // Test on UI Column
    $ui[ 'fields' ][ 'manage' ] = array(
        'city' => 'City',
        'region' => 'Region'
    );

    return $ui;
}

add_filter( 'pods_admin_ui_cities', 'pods_ui_test' );
share|improve this answer
    
This post was automatically marked as "low quality", probably because it is a block of code with little description. Though it may be obvious to you, and to many here, what this does you could make the answer meaningful to less knowledgeable users by providing a little bit of commentary. –  s_ha_dum Feb 4 '13 at 16:15
    
I'll include more explanation when I get some time later today, was just getting him what he needed ASAP. –  Scott Kingsley Clark Feb 4 '13 at 16:49
    
@ScottKingsleyClark: Awesome! That worked very well. thank you very much for the quick reply. Really appreciate that! –  gmaggio Feb 5 '13 at 2:23
    
@s_ha_dum: I think this answer is completing that which already exists in the question & the comments under it. Most of the details are in there. –  gmaggio Feb 5 '13 at 2:25
    
Thanks @ScottKingsleyClark you saved my life again :D –  noc2spam yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.