Note: This Blog is targeted to developers!

As Joomla developers, you might have come across an issue wherein you need zoo items which have specific value under specific field?

Let's say you have a site where there are some discount offers on some books under different categories. For such books to show up under offers module, you need to have one zoo field saying ‘Have offer?’ with value ‘yes’. Also, you might be aware that the way zoo stores its field values is very tricky and it will be a huge task to get such items using database query.

Zoo provides the api for it, named ‘SearchElements’.

So we need zoo items list having field as ‘Have offer?’ and value ‘yes’, then this api is for you.

Here is how it is done!

// Create the zoo instance
$app			= App::getInstance('zoo');

//Take an element id of the field you want to search for and its value. Create array of it as api requires associative array format for it.
$element_id  = array('7b53d24f-6e22-4b8b-bfd9-b33ecda4aa8a'=>'y');

// Here is the zoo api that you need to add. First parameter is element array and second is application id.
$itemlist = $app->table->item->searchElements($element_id, '1');


And $itemlist will provide you all searched items.

I hope now you will be able to search zoo items with field values :)