Show Repositories on Home page

81 views
Skip to first unread message

Roger Rutishauser

unread,
Jan 29, 2024, 7:24:04 PMJan 29
to AtoM Users
Hi,

In my custom theme (Bootstrap 2), I would like to show all repositories, just like the "card view" https://demo.accesstomemory.org/repository/browse 

In the file plugins/themeName/modules/staticpage/templates/homeSuccess.php, I have the following slot for this particular block on the home page:

<?php slot('home_repositories') ?>
  <?php echo get_partial('repository/browseCardView', array('pager' => $pager, 'selectedCulture' => $selectedCulture)) ?>
<?php end_slot() ?>


This does not work because $pager is not set, I assume. 

Is there a better/easier way to get all repositories in an object or nested array, with title, link and image, so I can loop through myself?

Cheers,
Roger

Alberto Pereira

unread,
Jan 30, 2024, 2:45:22 PMJan 30
to ica-ato...@googlegroups.com
Hi,

I suppose there are a few ways you could go about doing that without delving too much into code:

- that $pager variable (with the results) is set on the corresponding action of the module. In this particular case, it is set in the RepositoryBrowseAction class, located at /apps/qubit/modules/repository/actions/browseAction.class.php.
    You can replicate the code (or part of it) in the plugins/themeName/modules/staticpage/actions/homeAction.class.php, which will make the variable available to the template, hence you can pass it down to the partial.
    You can strip most of the code depending on what you want to include on the home page. By removing the order, filters, subqueries, etc, it basically boils down to including the following code inside the execute function (right before the ending bracket):
    $this->limit = sfConfig::get('app_hits_per_page');
    $this->search = new arElasticSearchPluginQuery($this->limit, 0);

    $resultSet = QubitSearch::getInstance()->index->getType('QubitRepository')->search($this->search->query);

    $this->pager = new QubitSearchPager($resultSet);
    $this->pager->setPage($request->page ? $request->page : 1);
    $this->pager->setMaxPerPage($this->limit);
    $this->pager->init();

- another way is to copy the generated HTML if the repositories are rarely changed.

- or make an ajax call to the browse repositories page, scrape the HTML "masonry" section, and add it to the home page content.


    

--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/6ff98d55-c843-4502-b8c1-3ff7ec073c8fn%40googlegroups.com.

Roger Rutishauser

unread,
Jan 31, 2024, 3:56:17 AMJan 31
to AtoM Users
Thanks a lot Alberto! I tried the first solution and it works fine.
Reply all
Reply to author
Forward
0 new messages