Item Show based on Item Set

I need to customize show.phtml to display different properties based on item sets to whom the item belongs.
I’m trying to use $item->itemSets() objects without a clear view of what is the best way to proceed.
Can anyone suggests me a solution or give me a link to docs for developer where I can find in formation on how to use these objects and the releated properties and methods?
Thanks a lot!

Sorry, for some reason I didn’t see the Core Documentation!
This should be the right place: https://omeka.org/s/docs/developer/reference/apigendocs/current/Entity/index.html
Anyway, if someone want to suggest me a good way to select properties based on item sets of an item, that will be very much welcome!
Thanks!

In theme files, you don’t manage Entity objects but Representation objects.

ItemRepresentation::itemSets() return an array of ItemSetRepresentation objects. If you want to filter according to item set name, you have to use ItemSetRepresentation::displayTitle() in your condition.

$itemSets = $item->itemSets();
$itemSetNames = array_map($itemSets, function($set){ return $set->displayTitle(); } );
if (in_array("My item set", $itemSetNames))
  echo $item->displayTitle();
else
  return;

Note I haven’t tried this code, I’m not sure about array_map() syntax.

1 Like