Getting field values from item through PHP

Answered

Comments

4 comments

  • Andreas Haugstrup Pedersen

    Use the "field" method to get a specific field. E.g.:

    $item = PodioItem::filter(7140799);
    echo $item["items"][0]->field(YOUR_FIELD_ID)->values[0]["value"];

    1
    Comment actions Permalink
  • Robert Priewe

    Oh my god thank you this is exactly what I was looking for! I searched everywhere for this, maybe you should add this to the examples in the future as its pretty useful!

    For everyone else running into this in the future, this will return an array. So you will still need to define which value of the field you need. For example if the field is the contact info with the name, this will give you the name:
    echo $item["items"][0]->field(YOUR_FIELD_ID)->values[0]["value"]["name"];

    If your field is a picture, this will get you the thumbnail URL:
    echo $item["items"][0]->field(YOUR_FIELD_ID)->values[0]["value"]["thumbnail_link"];

    Thanks again for the fast answer Andreas you are a life saver!

    0
    Comment actions Permalink
  • Robert Priewe

    One more question...is there a way to sort everything by a specific field_id? Lets say I want to retrieve every items of an app and order everything by field_id 55428207 which is a contact and the value name? This would be the structure: $item["items"][0]->field(55428207)->values[0]["value"]["name"]
    Ive tried playing around with order_by parameters but it didnt work
    Thanks!

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    You can sort on some fields but not all. You can see the a list in the documentation: https://developers.podio.com/doc/filters

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk