praiadeseselle/site/templates/atopar.php

103 lines
3.1 KiB
PHP
Raw Permalink Normal View History

<?php namespace ProcessWire;
/** @var Page $page */
/** @var Pages $pages */
/** @var Config $config */
/** @var Sanitizer $sanitizer API variable */
/** @var WireInput $input API variable */
/** @var User $user API variable */
/** @var Languages $languages API variable */
/** @var SiteConfig $configuracion */
/** @var HomePage $inicio */
2023-03-11 12:53:47 +01:00
$atopar = $sanitizer->text($input->get('q'));
$menu = '';
2023-03-11 12:53:47 +01:00
if($configuracion['mantemento']['activo'] && !$user->isLoggedin())
{
$menu = renderMenu($inicio->and($pages->get('/noticias')->and($pages->get('/contacto'))));
}
else
{
$menu = renderMenu($inicio->and($inicio->children));
2023-03-11 12:53:47 +01:00
}
?>
<main id="contido" class="completo">
<nav id="migas" aria-label="<?=_x("Breadcrumb", "Breadcrumb");?>">
<?=renderMigasPan($page);?>
</nav>
<?php
2023-03-11 12:53:47 +01:00
if($atopar)
{
$input->whitelist('q', $atopar);
$atopar = $sanitizer->selectorValue($atopar);
2023-03-11 12:53:47 +01:00
$selector = "";
$selector .= "(title|seccions.titular|seccions.artigo~=$atopar)";
$selector .= ",(seccions.destacados.titular~=$atopar)";
$selector .= ",(seccions.destacados.artigo~=$atopar), limit=50";
if($user->isLoggedin()) $selector .= ", has_parent!=2";
$matches = $pages->find($selector);
2023-03-11 12:53:47 +01:00
$cnt = $matches->count;
2023-03-11 12:53:47 +01:00
if($cnt)
{
?>
<article id="<?=$page->name;?>">
<h1 class="visually-hidden"><?=ucfirst($page->title);?></h1>
<h2>Resultados para: <?=$atopar;?></h2>
<p><?=sprintf(_n(_x('Found %d page', 'found 1 page'),_x('Found %d pages', 'found multiple pages'), $cnt), $cnt);?></p>
<section>
<h3 class="accesibilidade-oculto"><?=_x("Search results", "search results");?></h3>
<ul class="lista">
<?php foreach($matches as $paxina): ?>
<li class="info">
<a href="<?=$paxina->url;?>"><i class="icon-play"></i> <?=$paxina->title;?></a>
</li>
<?php endforeach;?>
</ul>
</section>
</article>
<?php
}
else
{
?>
<article id="<?=$page->name;?>" class="destacado">
<h1 class="visually-hidden"><?=ucfirst($page->title);?></h1>
<h2><?=_x('Sitemap', 'sitemap');?></h3>
<p><?=_x('Sorry, no results were found', 'no results found');?>.</p>
<section>
<h3 class="accesibilidade-oculto"><?=_x('Sitemap', 'sitemap');?></h3>
<nav id="mapa-sitio">
<?=renderMapaDoSitio($inicio, 3);?>
</nav>
</section>
</article>
<?php
}
2023-03-11 12:53:47 +01:00
}
else
{
?>
<article id="<?=$page->name;?>" class="destacado">
<h1 class="visually-hidden"><?=ucfirst($page->title);?></h1>
<h2><?=_x('Sitemap', 'sitemap');?></h3>
<p><?=_x('Sorry, no results were found', 'no results found');?>.</p>
<section>
<h3 class="accesibilidade-oculto"><?=_x('Sitemap', 'sitemap');?></h3>
<nav id="mapa-sitio">
<?=renderMapaDoSitio($inicio, 3);?>
</nav>
</section>
</article>
<?php
2023-03-11 12:53:47 +01:00
}
?>
</main>
<?php