Hello,
I am adapting an Omeka-S theme, and would like to adjust the show.phtml file to display the linked resources of an item the same way it does the item showcase block. I found the item showcase code and am trying to integrate it into the phtml page
I imagine that i need to at least being with changing the line
<?php foreach ($attachments as $attachment): ?>
to be something like foreach linked item to this item with certain conditions (such as select every item that is an image that is linked to this image in this particular field)…and then each of those to be displayed as the thumbnail with the link.
However I am not sure how to call the related items. I tried to look at the DisplaySubjectValues but can’t figure it out. Any guidance would be appreciated.
I think other items that link to the other item.
For example the main item on the page is a Theatre Production, and I want to link all the images that are of that Theatre Production (in the image resource there is a field called superevent which is a linked Omeka resource).
Thanks and hope that clarifies,
Sanjin
OK, so yes it sounds like you want items linking to the current one.
You can do $item->subjectValues() to get an array of all the values that link to $item. For each of those values, you can do $relatedResource = $value->resource(); to get the resource that’s linking in.
Then you should be able to pretty much use the “showcase” code but with $relatedResource standing in for the use of $item in that snippet you posted. There’s also other bits of code like the if blocks dealing with options of the Showcase block and you’ll have to deal with those as well, since there’s no block and therefore no options here.
I am going to have to ask for you to break it down for me a bit more, as i am new to php and am trying to figure out how Omeka works in the backend.
I have tried to follow what i understood from what you said:
But with this I get a Call to a member function resource() on array error. From what you said if linkeditemsarray is all the items that link to this item, then going through it should allow me to use your code to create the variable for each one in $relatedResource. Or is linkeditemsarry an array of arrays with all the information of the linked items.
I am trying to build a theme that alters the show item page based on the resource element of the item, so any documentation that you have around how to call the various functions to be able to access the resources of the item. I tried to look at Representations - Omeka S Developer Documentation but am not clever enough to figure it out at this point in time (maybe with experience).
Thanks for your time
The issue here is just that subjectValues() gives you a nested array back: it’s an array of arrays (each one the values for one property), so you just need another “level” of foreach.
A further development from this request. I would like to sort the list of items that link to this resource by their class, so that I can create a table each for Images/Audio/Videos, etc.
Something similar to the linked-resources.phtml code, but instead of grouping it by the property, rather to almost invert it, so that the list of resources that link to it is grouped by their class of the items.