makes a search from the Collections site render a collections list

This commit is contained in:
buttle 2021-05-31 16:58:51 +02:00
parent 406a92b3f7
commit 551ba6b214
4 changed files with 68 additions and 28 deletions

View File

@ -1,6 +1,5 @@
<?php <?php
$archiveSiteHelper = $this->getHelperPluginManager()->get('archiveSiteMeta'); $archiveSiteHelper = $this->getHelperPluginManager()->get('archiveSiteMeta');
$collections = $archiveSiteHelper->getCollections();
?> ?>
<div class="list-of-sites"> <div class="list-of-sites">
@ -17,11 +16,9 @@ $collections = $archiveSiteHelper->getCollections();
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach($sites as $site): foreach($sites as $site):
$site_meta_values = $archiveSiteHelper->getSiteMetaValues($site); $site_meta_values = $archiveSiteHelper->getSiteMetaValues($site);
//echo $this->partial('common/index/site-list-item', [
echo $this->partial('common/site-list-entry', [ echo $this->partial('common/site-list-entry', [
'site' => $site, 'site' => $site,
'showSummary' => $summaries, 'showSummary' => $summaries,
@ -36,7 +33,8 @@ $collections = $archiveSiteHelper->getCollections();
</div> </div>
<?php <?php
if ($pagination): if (1 == 0):
//if ($pagination):
echo $this->pagination(); echo $this->pagination();
endif; endif;
?> ?>

View File

@ -2,7 +2,10 @@
$fulltextSearch = $this->params()->fromQuery('fulltext_search'); $fulltextSearch = $this->params()->fromQuery('fulltext_search');
$hasResults = false; $hasResults = false;
?> ?>
<?php
//$archiveSiteHelper = $this->getHelperPluginManager()->get('archiveSiteMeta');
//$collections = $archiveSiteHelper->getCollections();
?>
<!-- arc-hive insert begins --> <!-- arc-hive insert begins -->
<?php <?php
@ -22,11 +25,14 @@ if (!$img_src) {
<script> <script>
<?php <?php
$_html = '<a href="'.$this->site->url().'">'.$this->site->title().'</a>';
/*
if ($this->site->title() != "Collections") { if ($this->site->title() != "Collections") {
$_html = '<a href="'.$this->site->url().'">'.$this->site->title().'</a>'; $_html = '<a href="'.$this->site->url().'">'.$this->site->title().'</a>';
} else { } else {
$_html = $this->site->title(); $_html = $this->site->title();
} }
*/
?> ?>
$("#archive_page_title").html('<?php echo $_html ?>'); $("#archive_page_title").html('<?php echo $_html ?>');
</script> </script>
@ -37,35 +43,66 @@ $("#archive_page_title").html('<?php echo $_html ?>');
<div class="results"> <div class="results">
<?php <?php
if ($responseSitePages && $responseSitePages->getTotalResults()): if ($this->site->title() == "Collections") {
/* convert all the results into sites and display the list of sites */
$result = array();
if ($responseSitePages && $responseSitePages->getTotalResults()) {
$hasResults = true; $hasResults = true;
?> foreach ($responseSitePages->getContent() as $sitePage) {
<?php $site = $sitePage->site();
$sitePages = array(); array_push($result, $site);
foreach ($responseSitePages->getContent() as $sitePage) { }
array_push($sitePages, $sitePage); }
} if ($responseItems && $responseItems->getTotalResults()) {
echo $this->partial('common/cross-site-search/site-page-results', [
'sitePages' => $sitePages,
]);
?>
<?php endif; ?>
<?php
if ($responseItems && $responseItems->getTotalResults()):
$hasResults = true; $hasResults = true;
?> foreach ($responseSitePages->getContent() as $sitePage) {
<?php $site = $sitePage->site();
$items = array(); if (!in_array ($site , $result)) {
foreach ($responseItems->getContent() as $item) { array_push($result, $site);
array_push($items, $item);
} }
echo $this->partial('common/cross-site-search/item-results', [ }
'items' => $items, }
]); echo $this->partial('common/block-layout/list-of-sites', [
'sites' => $result,
'summaries' => 1,
]);
} else {
/* display the results as normal */
?>
<?php
if ($responseSitePages && $responseSitePages->getTotalResults()):
$hasResults = true;
?> ?>
<?php endif; ?> <?php
$sitePages = array();
foreach ($responseSitePages->getContent() as $sitePage) {
array_push($sitePages, $sitePage);
}
echo $this->partial('common/cross-site-search/site-page-results', [
'sitePages' => $sitePages,
]);
?>
<?php endif; ?>
<?php
if ($responseItems && $responseItems->getTotalResults()):
$hasResults = true;
?>
<?php
$items = array();
foreach ($responseItems->getContent() as $item) {
array_push($items, $item);
}
echo $this->partial('common/cross-site-search/item-results', [
'items' => $items,
]);
?>
<?php endif; ?>
<?php } ?>
</div> </div>
<?php if (!$hasResults): ?> <?php if (!$hasResults): ?>
<p><?php echo $this->translate('No result found'); ?> <p><?php echo $this->translate('No result found'); ?>
<?php endif; ?> <?php endif; ?>

View File

@ -4,6 +4,8 @@ $archiveSiteHelper = $this->getHelperPluginManager()->get('archiveSiteMeta');
$archive_collections = $archiveSiteHelper->getCollections(); $archive_collections = $archiveSiteHelper->getCollections();
?> ?>
<!-- <h2><?php echo sprintf($this->translate('Site page results for "%s"'), $fulltextSearch); ?></h2> --> <!-- <h2><?php echo sprintf($this->translate('Site page results for "%s"'), $fulltextSearch); ?></h2> -->

View File

@ -22,11 +22,14 @@ if (!$img_src) {
</style> </style>
<script> <script>
<?php <?php
$_html = '<a href="'.$this->site->url().'">'.$this->site->title().'</a>';
/*
if ($this->site->title() != "Collections") { if ($this->site->title() != "Collections") {
$_html = '<a href="'.$this->site->url().'">'.$this->site->title().'</a>'; $_html = '<a href="'.$this->site->url().'">'.$this->site->title().'</a>';
} else { } else {
$_html = $this->site->title(); $_html = $this->site->title();
} }
*/
?> ?>
$("#archive_page_title").html('<?php echo $_html ?>'); $("#archive_page_title").html('<?php echo $_html ?>');
</script> </script>