Search code examples
podio

Get item filtered by specific tag and custom field


I would like to get an item filtered by a specific tag AND order by a custom date field (extern ID is 'date')

I've tried multiple way according to the doc, such as PodioItem::Filter() with an array for the tag and a simple string too, but I didn't get expected result.

I know we can filter by tags and order by specific field ID, but I don't know how to do it.

Explaination from doc:

tags: Filter by the tags on the item
{field_id}: The id of the field to sort by, which can be fields of type "state", "text", "location", "money", "number", "calculation", "progress", "duration", "app", "date", "contact", "category" and "question".

Does anyone knows how to do it?

Thanks to all!


Solution

  • At the very bottom of this page http://podio.github.io/podio-php/items/ you can see how to do date filters. You can combine that with tags like so:

    $items = PodioItem::filter($app_id, array(
      'filters' => array(
        $external_id_of_date_field => array(
          "from" => "2014-01-01 00:00:00",
          "to" => "2014-07-31 23:59:59"
        ),
        'tags' => array('tag1')
      ),
    ));