Best way to get item details? stay in filter_by_view, or jump to get_item?

Answered

Comments

1 comment

  • Andreas Haugstrup Pedersen

    Hi Roy,

    The filter methods return a collection of PodioItem instances. Have you seen the examples in https://github.com/podio/podio-php/blob/master/examples/items.php and the class files for PodioItem https://github.com/podio/podio-php/blob/master/models/PodioItem.php and PodioItemField https://github.com/podio/podio-php/blob/master/models/PodioItemField.php ?

    You shouldn't have to deal with the underlying arrays very much. For example if you have an item and want to grab the title of the first referenced item in the field with the external id of 'app-reference' (this could be written in fewer lines, if you want to chain the method calls):

    $item = PodioItem::get($item_id);

    $field = $item->field('api-reference'); // Returns PodioItemField instance when given external_id

    $references = $field->items(); // Returns list of PodioItem instances

    print $references[0]->title;

    If you look in class file for PodioItemField you can see that app reference fields are instances of PodioAppItemField and they have a method called 'items' that will return a list of PodioItem instances for the references (similar methods are available for contact fields, image fields etc.).

    Does that help?

    All the best,

    Andreas 

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk