Multiple collections on homepage

I would like to display multiple collections on the homepage (preferably, filtered by most recent, but I’ll settle for just about any way to show multiple collections).

The following Omeka codex page has a function on it that seems to address this issue, but I’m not sure how to add/call the function from within the theme’s index.php.

https://omeka.org/codex/Recipes/Multiple_Featured_Collections

It seems like the code on this page is the first part of a 2-step process. I added the function to functions.php. But I’m not sure how to call the function in index.php.

Any guidance on this would be appreciated! Thanks!

That example is for the much older Omeka 1.x series, not the current Omeka 2.x series.

For Omeka 2.x, you’ll want to use get_records() to find the collections you want.

Then, to display them, use the partial that random_featured_collection uses:


$html = get_view()->partial("collections/single.php", array("collection" => $collection));

That all would go into your theme index.php file, replacing what currently displays the collection (if it is there)


$collections = get_records('Collection');

foreach ($collections as $collection) {
echo get_view()->partial('collections/single.php', array('collection' => $collection));
}

It could probably be done more elegantly, but that’s the basic idea.

I would have to say that is pretty elegant. Works perfectly.

Thank you!