How to access a nested PICK column data from a bi-directional PICK array

0

Hello everyone,

I'll try to explain what I'm trying to do.

I've got 3 Pods: Productions, Credits and People

  1. Productions Pod - has got a multi-pick, bi-directional field "credits" that relates to the field "production_fk" in the Credits Pod
  2. Credits Pod - has got a bi-directional field "production_fk" that relates to the field "credits" in the Productions Pod
  3. Credits Pod - has got a PICK field "person" that relates to the field "name" in the People Pod

What I'm trying to do is to get all the credits for a production (is working) and display corresponding person's name (can't get working).

Code:

<?php
        $found_production = false;

        global $pods;
        $production_slug = pods_url_variable(-1);
        $production = new Pod('productions', $production_slug);

        if( !empty($production->data) ) {
            $found_production = true;

            // credits for the specified production
            $credits = $production->get_field('credits');
            $credits_count = count($credits);
        }
    ?>

When I var\_dump($credits) it contains all the fields in the Credits Pod, exept PICK fields ("production_fk" and "person"). How can I access the PICK fields data??

Would really appreciate any help! Thanks

asked Sep 28 '10 at 5:51

dashaluna

54

add comment
enter at least 15 characters

3 Answers

1

This is a three level (Productions->Credits->Person) structure, and pods can go only two levels deep yet. So it should be done as Scott said: get credits.id, make a WHERE clause out of it ('WHERE t.id = a OR b OR c etc'), call a new pod for credits, then apply findRecords() using this clause. After that you can go through related Credits data (just a standard loop using fetchRecord as in examples), including it's pick field.

answered Sep 29 '10 at 6:41

Fike

208

add comment
enter at least 15 characters
0

To get PICK data, start a new Pod() for the related Pod and Item ID and get the info that way.

answered Sep 28 '10 at 7:20

sc0ttkclark

2936

add comment
enter at least 15 characters
0

If you want only some simple data, you can use dot traversal trick for get_field().

$production->get_field('credits.production_fk');

You will get array of traversed pick column (not recommended to use for multiple relations).

answered Sep 29 '10 at 10:53

pavelevap

3

add comment
enter at least 15 characters