Advertisement
uzielweb

Joomla Search based on Categories View

Jun 13th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.92 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_search
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC') or die;
  11.  
  12. $category = JTable::getInstance('category');
  13. $category_searched = $this->params->get('category');
  14. $recount = '0';
  15.  
  16. ?>
  17. <dl class="search-results<?php echo $this->pageclass_sfx; ?>">
  18. <?php foreach ($this->results as $result) : ?>
  19. <?php
  20.  
  21. $category->load($result->catid);
  22.  
  23.  ?>
  24.  <?php if (($category->id == $category_searched)  or ($category->parent_id == $category_searched )) : ?>
  25.  
  26.     <dt class="result-title">
  27.  
  28.         <?php echo $this->pagination->limitstart + ($recount++) + 1 . '. '; ?>
  29.         <?php if ($result->href) : ?>
  30.             <a href="<?php echo JRoute::_($result->href); ?>"<?php if ($result->browsernav == 1) : ?> target="_blank"<?php endif; ?>>
  31.                 <?php // $result->title should not be escaped in this case, as it may ?>
  32.                 <?php // contain span HTML tags wrapping the searched terms, if present ?>
  33.                 <?php // in the title. ?>
  34.                 <?php echo $result->title; ?>
  35.             </a>
  36.         <?php else : ?>
  37.             <?php // see above comment: do not escape $result->title ?>
  38.             <?php echo $result->title; ?>
  39.         <?php endif; ?>
  40.     </dt>
  41.     <?php if ($result->section) : ?>
  42.         <dd class="result-category">
  43.             <span class="small<?php echo $this->pageclass_sfx; ?>">
  44.                 (<?php echo $this->escape($result->section); ?>)
  45.             </span>
  46.         </dd>
  47.     <?php endif; ?>
  48.     <dd class="result-text">
  49.         <?php echo $result->text; ?>
  50.     </dd>
  51.     <?php if ($this->params->get('show_date')) : ?>
  52.         <dd class="result-created<?php echo $this->pageclass_sfx; ?>">
  53.             <?php echo JText::sprintf('JGLOBAL_CREATED_DATE_ON', $result->created); ?>
  54.         </dd>
  55.     <?php endif; ?>
  56.     <?php endif; ?>
  57. <?php endforeach; ?>
  58. </dl>
  59.  
  60. <div class="pagination">
  61.  
  62.     <?php echo $this->pagination->getPagesLinks(); ?>
  63. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement