Is there a function I can use to suppress display of ItemRelations?

I’m looking for a way to not show the ItemRelations public_items_show block if the item has no relations. Right now, it always shows up, with “This item has no relations.”

I can modify the plugin, but I’d rather find some way to decide it from within the item’s show page. Like a hasRelationships function, or some way to find it from metadata.

Thanks.

The check can be done, but a deeper problem might come from choosing the right plugin output from the public_items_show hook. That’s what lets Item Relations insert its content, but it’s also what other plugins use to add content to the page. Thus, if you have other plugins that use that hook, you’ll have to work around those.

The simple version, if there’s no other plugins to worry about would work like this.

There’s not a single function, but it looks like you could check it the way the plugin does internally:

$subjectRelations = ItemRelationsPlugin::prepareSubjectRelations($item);
$objectRelations = ItemRelationsPlugin::prepareObjectRelations($item);

if (!$subjectRelations && !$objectRelations) {
// don't show the relations
} else {
// show the relations
}

If you do have to work around different plugins, you’d have to switch to using get_specific_plugin_hook_output() on each of the plugins.

1 Like

That worked perfectly. Thanks