Query all sites within an installation

I am building a new installation of Omeka S with multiple Sites that will all share a custom theme, but I’m hoping to have a global navigation to list and link to all Sites added to the install.

This is my first time using Omeka and Zend, so I’m not sure the best approach. First attempt was to replicate the controller found at /application/src/Controller/IndexController.php. This creates the $sites variable that is used on the default installation homepage. I just need this to be an accessible variable within my custom theme template pages.

I created /modules/MyModule/src/Controller/Site/IndexController.php with the code taken from the above controller, updated the namespace and removed the section about redirecting to the default site.

namespace MyModule\Controller\Site;

use Omeka\Api\Exception as ApiException;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
    public function indexAction()
        $response = $this->api()->search('sites');
        $this->paginator($response->getTotalResults(), $this->params()->fromQuery('page'));

        $view = new ViewModel;
        $view->setVariable('sites', $response->getContent());
        return $view;

I also added the following in my module.config.php file

'controllers' => [
     'invokables' => [
         'Omeka\Controller\Site' => 'ConnectedSites\Controller\Site',

However, $sites is still undefined in my themes view files :’(

I imagine I am close (or so I hope), but there is clearly something missing. Suggestions?


Hi Corey,

I’m new to Omeka development but FWIW I’ve found that $this->api()->search('sites'); will not return sites that are set to private.

Also, have you instructed your module to load module.config.php? This should be declared in your Module.php file:

    public function getConfig ()
        return include __DIR__ . '/config/module.config.php';

I’ve found this was not totally straightforward in the documentation.

Have a nice day!



Your controller method isn’t going to work by itself… a controller only gets used if there’s a route for it, so you’d have to configure some routing at least.

Do I understand correctly that you’re trying to build a page within a site that would link to all the other sites?

This use case is something we’re looking at as well, to give people tools to customize the “Home” or “Index” type page we’ve got now.

Thanks Man! I do have that written in my Module.php, in fact the only function in there, apologies for not mentioning that. This response was however very helpful for just having mentioned the idea of private sites; I hadn’t even noticed that private-eye icon until I went looking for it!

Thanks for the response! I’ll read the routing docs now and see what I can do next.

My intention has changed a bit since my original post, though I think what I had written is still all relevant. I will now be doing exactly what you are describing with a Home/Index site set as default for the installation. There will be several “exhibits” created as other sites, all with multiple pages.

All of the sites will share a theme that I am creating that will have a navigation in the header that lists out all other sites on the install.

I know a similar structure can be created by using multiple pages and subpages with a nested navigation (since I am using the same theme), but this approach seemed more appropriate in terms of the hierarchical structure of the backend and the URLs. It is also a student project that I want each group to work within their own “site” so there are not too many cooks in the digital kitchen.