Add item set to all pages

I am hoping to add item sets (or preferably item set trees) as a sidebar to all pages (to mimic an existing website).

I had hoped that copying the "foreach ($itemSets as $itemSet): " section of code from item-set/browse.phtml to layout.phtml would be a good starting point, but $itemSets is undefined (and I cannot find where it is created).

Ideally I would like to check it the module item set tree is installed and if so display a tree, and drop back to item sets if it is not installed.


Omeka is built with the common structure “model-view-controller” (mvc), so all variables in views come from the controllers (so variables from item-set/browse come from file “application/src/Controller/Site/ItemSetController.php” and function “browseAction”).

There are two ways to get the item sets in the theme: use a specific function (the module ItemSetTree has such a function) or directly from the api:

$itemSets = $this->api()->search('item_sets', ['site_id' => $siteId])->getContent();

Thank you, your suggestion works perfectly.

I have installed the Item Sets Tree plugin module, and I have attempted to extract the itemSetsTree information using the following.

<?php  $itemSetsTree = $this->itemSetsTree(); ?>
	<?php if (!empty($itemSetsTree)): ?>
	<p>Tree not empty!</p>
        <?php foreach ($itemSetsTree as $itemSetsTreeNode): ?>
			<p> Next Node</p>
                <a href="<?php echo $itemSetsTreeNode['itemSet']->url(); ?>"><?php echo $this->escapeHtml($itemSetsTreeNode['itemSet']->displayTitle()); ?></a>
                <?php echo $this->partial('item-sets-tree/item-sets-tree', ['itemSetsTree' => $itemSetsTreeNode['children']]); ?>
        <?php endforeach; ?>
	<?php endif; ?>

The test shows that the tree is not empty, but the foreach loop returns nothing at all.

Any thoughts?

Please ignore this!! I will have problems with dependencies (theme requiring module/plugin to be present), I think what I need is a version/edit of the ItemSetTrees module which allows the tree to be added and styled as a block. From comments on GitHub this appears to be in the next release of this module. I can then add block and style as a sidebar.


This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.