Sorting Linked Resources in public display

I recently upgraded a site from an earlier version of Omeka S to 4.x, and I’m running into an issue with the display of linked resources.

On the old version of the site, if we were careful about the order that we added linked resources on the admin side, they would display in the same order on the public site.

Now, they values that show up in the item metadata view on the admin are in the correct order under “has part”, but when I click over to the Linked Resources tab, they’re alphabectical. This is the same on the public site. I’ve built my own phtml template to remove the table and add expand/collapse functionality for lists over 5 items (see, but I’ve checked that the default Linked Resource display does the same thing.

I would prefer to sort these items by a metadata field other than title (optimally the custom report number field that is disaplyed below the title in the example shown above). I am sure there’s a way to use php to sort these values in my template, but I keep running into trouble trying to do so, and I wanted to see if anyone here knew if there was a more obvious or easy option that I’m missing. It doesn’t seem like we ought to be stuck with alphabetical ordering, but I suppose that very technically, Dublin Core’s “has part” element does not allow for ordering, so perhaps Omeka’s approach is correct…I’m hoping someone else has found (or coded) a solution, however.


For anyone who’s curious, I eventually figured out how to solve this problem. The thing that kept tripping me up was accessing the custom metadata field I wanted to use to sort within the php sort function. I ended up avoiding that problem by putting the data to sort into a variable and then sorting that way:

<?php $Reports=[]; ?>

<?php foreach ($values as $value): ?>
<?php $Reports[] = [
    'link' => $value['val']->resource()->linkPretty('square', null, null, null, $valueLang),
    'ID' => $value['val']->resource()->value('custom:reportNumber')
]; ?>
<?php endforeach; ?>

<!-- Sort reports by Report number -->
<?php uasort($Reports, function($a, $b) {return $a['ID'] <=> $b['ID'];}); ?>
<?php foreach ($Reports as $Report): ?>

Within the foreach I used the variables above to print the metadata values I wanted in the linked resource list (in this case, just a link and the report number.