Создание фильтра для отбора по дополнительным полям.
Для того, чтобы в списке категории можно было создать фильтр материалов по каким либо параметрам заданным в дополнительных полях материала, надо создать плагин модифицирующий запрос к базе данных перед его отправкой.
Для этого надо создать точку подключения плагина в методе getListQuery класса ContentModelArticles и создать плагин редактирующий запрос.
В свою очередь, для создания точки прерывания, можно воспользоваться плагином
edit_contentmodelcategory.xml
<?xml version="1.0" encoding="utf-8"?> <install version="1.5" method="upgrade" type="plugin" group="system"> <name>Edit_contentmodelcategory</name> <creationDate>2013-05-19</creationDate> <author>Vadim Rigin</author> <authorEmail>vadim@rigin.net</authorEmail> <authorUrl>http://www.rigin.net</authorUrl> <copyright>Copyright (C) 2013 Vadim Rigin Open Source Matters. All rights reserved.</copyright> <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license> <version>1</version> <description></description> <files> <filename plugin="edit_contentmodelcategory">edit_contentmodelcategory.php</filename> <filename>index.html</filename> <filename>articles.php</filename> </files> </install>
edit_contentmodelcategory.php
<?php // No direct access defined('_JEXEC') or die; $app = JFactory::getApplication(); if($app->isSite()) { // Считываем базовый класс ContentModelArticles . $ContentModelArticlesOld = implode('',file(JPATH_ROOT . '/components/com_content/models/articles.php')); // переименовываем его $ContentModelArticlesOld = str_replace ( ' ContentModelArticles ', ' ContentModelArticles_Edit_contentmodelcategory ', $ContentModelArticlesOld ); // отрезаем <?php $ContentModelArticlesOld = substr($ContentModelArticlesOld,5); // запускаем переименованный класс eval($ContentModelArticlesOld); // Вызываем новый класс ContentModelArticles на замену include_once JPATH_ROOT . '/plugins/system/edit_contentmodelcategory/articles.php'; }
articles.php
<?php /** * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * This models supports retrieving lists of articles. * * @package Joomla.Site * @subpackage com_content * @since 1.6 */ class ContentModelArticles extends ContentModelArticles_Edit_contentmodelcategory { function getListQuery () { $query = & parent::getListQuery(); $dispatcher = & JDispatcher::getInstance(); JPluginHelper::importPlugin( 'content' ); $dispatcher->trigger( 'onContentAfterGetListQuery',array( & $query, & $this)); return $query; } }
Или сделать соответствующий хак с помощью компонента JHack
Примечание: при переопределении класса плагином, если вы создаете страницы списка избранных материалов, необходимо переопределить класс ContentModelFeatured, убрав строку
require_once dirname(__FILE__) . '/articles.php';
в начале файла
Теперт собственно плагин коррекции запроса. Он приводится для примера и зависит от конкретного набора параметров поиска.
search_kotedje.xml
<?xml version="1.0" encoding="utf-8"?> <install version="1.5" method="upgrade" type="plugin" group="content"> <name>Search_kotedje</name> <creationDate>2013-05-18</creationDate> <author>Vadim Rigin</author> <authorEmail>vadim@rigin.net</authorEmail> <authorUrl>http://www.rigin.net</authorUrl> <copyright>Copyright (C) 2013 Vadim Rigin Open Source Matters. All rights reserved.</copyright> <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license> <version>1</version> <description></description> <files> <filename plugin="search_kotedje">search_kotedje.php</filename> <filename>index.html</filename> </files> </install>
search_kotedje.php
<?php // No direct access defined('_JEXEC') or die; jimport('joomla.plugin.plugin'); class plgContentSearch_kotedje extends JPlugin { /** * Example prepare content method * * Method is called by the view * * @param string The context of the content being passed to the plugin. * @param object The content object. Note $article->text is also available * @param object The content params * @param int The 'page' number * @since 1.6 context = "com_content.articles" public function onContentPrepare($context, &$article, &$params, $limitstart) { $app = JFactory::getApplication(); if ($app->isAdmin() or $context != 'com_content.category') return true; dump($article,'$article');dump($params,'$params');dump($limitstart,'$limitstart'); }*/ public function onContentAfterGetListQuery($query, $_this) { $app = JFactory::getApplication(); if ($app->isAdmin()) return true; $jinput = $app->input; $paramrequest = $jinput->getArray($_POST)+$jinput->getArray($_GET); if(!isset($paramrequest['option']) || $paramrequest['option'] != "com_content") return TRUE; if($paramrequest['view'] == "category") { if($paramrequest['layout']== "usertemplate:catalogkotedg") { $typDom = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 1)'; $Garazh = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 2)'; $bass = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 3)'; $etazh = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 4)'; $S = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 5)'; $price = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 6)'; $query->join('LEFT',$typDom.' AS typDom ON typDom.articleid = a.id') ->join('LEFT',$Garazh.' AS Garazh ON Garazh.articleid = a.id') ->join('LEFT',$bass.' AS Bass ON Bass.articleid = a.id') ->join('LEFT',$etazh.' AS Etazh ON Etazh.articleid = a.id') ->join('LEFT',$S.' AS sObsh ON sObsh.articleid = a.id') ->join('LEFT',$price.' AS price ON price.articleid = a.id') ->select(array('typDom.value AS typDom','Garazh.value AS Garazh','Bass.value AS Bass', 'Etazh.value AS Etazh','sObsh.value AS sObsh','price.value AS price')); if (isset($paramrequest['typDom'])) { $aa = ''; foreach ($paramrequest['typDom'] as $a) { $aa .= $query->q($a).','; }; $aa = substr($aa,0,strlen($aa)-1); $query->where( "typDom.value IN ($aa)"); }; if (isset($paramrequest['Garazh'])) { $aa = ''; foreach ($paramrequest['Garazh'] as $a) { $aa .= (int)$a.','; }; $aa = substr($aa,0,strlen($aa)-1); $query->where( "Garazh.value IN ($aa)"); }; if (isset($paramrequest['bass'])) { $aa = ''; foreach ($paramrequest['bass'] as $a) { $aa .= (int)$a.','; }; $aa = substr($aa,0,strlen($aa)-1); $query->where( "Bass.value IN ($aa)"); }; if (isset($paramrequest['etazh'])) { $aa = ''; foreach ($paramrequest['etazh'] as $a) { $aa .= (int)$a.','; }; $aa = substr($aa,0,strlen($aa)-1); $query->where( "Etazh.value IN ($aa)"); }; if (isset($paramrequest['minS']) and isset($paramrequest['maxS']) ) $query->where('sObsh.value BETWEEN '.(int)$paramrequest['minS'].' AND '.(int)$paramrequest['maxS']); if (isset($paramrequest['minPrice']) and isset($paramrequest['maxPrice']) ) $query->where('price.value BETWEEN '.(int)$paramrequest['minPrice'].' AND '.(int)$paramrequest['maxPrice']); } elseif($paramrequest['layout']== "usertemplate:catalogtaunhouse") { $typDom = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 1)'; $Garazh = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 2)'; $bass = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 3)'; $etazh = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 4)'; $S = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 5)'; $price = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 6)'; $query->join('LEFT',$typDom.' AS typDom ON typDom.articleid = a.id') ->join('LEFT',$Garazh.' AS Garazh ON Garazh.articleid = a.id') ->join('LEFT',$bass.' AS Bass ON Bass.articleid = a.id') ->join('LEFT',$etazh.' AS Etazh ON Etazh.articleid = a.id') ->join('LEFT',$S.' AS sObsh ON sObsh.articleid = a.id') ->join('LEFT',$price.' AS price ON price.articleid = a.id') ->select(array('typDom.value AS typDom','Garazh.value AS Garazh','Bass.value AS Bass', 'Etazh.value AS Etazh','sObsh.value AS sObsh','price.value AS price')); } elseif($paramrequest['layout']== "usertemplate:cataloggaraj") { $typDom = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 1)'; $Garazh = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 2)'; $bass = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 3)'; $etazh = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 4)'; $S = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 5)'; $price = '(SELECT fv.value, fv.articleid '. 'FROM #__fieldsattach_values AS fv '. 'JOIN #__fieldsattach_groups AS fg ON fg.note = '.$query->q('g1').' '. 'JOIN #__fieldsattach AS fa ON fa.groupid = fg.id AND fv.fieldsid = fa.id '. 'WHERE fa.ordering = 6)'; $query->join('LEFT',$typDom.' AS typDom ON typDom.articleid = a.id') ->join('LEFT',$Garazh.' AS Garazh ON Garazh.articleid = a.id') ->join('LEFT',$bass.' AS Bass ON Bass.articleid = a.id') ->join('LEFT',$etazh.' AS Etazh ON Etazh.articleid = a.id') ->join('LEFT',$S.' AS sObsh ON sObsh.articleid = a.id') ->join('LEFT',$price.' AS price ON price.articleid = a.id') ->select(array('typDom.value AS typDom','Garazh.value AS Garazh','Bass.value AS Bass', 'Etazh.value AS Etazh','sObsh.value AS sObsh','price.value AS price')); } } } }
Далее надо переопределить вывод списка материалов категории в шаблоне, прочитав нужные параметры из запроса и создав форму самого фильтра. Форму фильтра можно включить в шаблон списка категории, или оформить в виде модуля.
Вот шаблон вывода списка материалов категории:
catalogkotedg.php
<?php /** * @package Joomla.Site * @subpackage com_content * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // no direct access defined('_JEXEC') or die; JHtml::addIncludePath(JPATH_COMPONENT.'/helpers'); $app = JFactory::getApplication('site'); $template = $app->getTemplate(true); $this->document->addStyleSheet($this->baseurl.'/templates/'.$template->template.'/css/jquery-ui-1.10.3.custom.css'); $this->document->addScript($this->baseurl.'/templates/'.$template->template.'/js/jquery-ui-1.10.3.custom.js'); $minS = $this->params->get('minS'); $maxS = $this->params->get('maxS'); $minPrice = $this->params->get('minPrice'); $maxPrice = $this->params->get('maxPrice'); $jinput = JFactory::getApplication()->input; $this->siarchparam = $jinput->getArray($_POST)+$jinput->getArray($_GET); if (isset($this->siarchparam['typDom'])) foreach ($this->siarchparam['typDom'] as $a) $typDom[$a] = 1; if (isset($this->siarchparam['Garazh'])) foreach ($this->siarchparam['Garazh'] as $a) $Garazh[$a] = 1; if (isset($this->siarchparam['bass'])) foreach ($this->siarchparam['bass'] as $a) $bass[$a] = 1; if (isset($this->siarchparam['etazh'])) foreach ($this->siarchparam['etazh'] as $a) $etazh[$a] = 1; $script = ' $(document).ready(function(){ /* слайдер цен */ $("#slider-2").slider({ min: '.$minPrice.', max: '.$maxPrice.', values: ['.(isset($this->siarchparam['minPrice'])? $this->siarchparam['minPrice']:$minPrice).','.(isset($this->siarchparam['maxPrice'])? $this->siarchparam['maxPrice']:$maxPrice).'], range: true, stop: function(event, ui1) { $("input#minPrice").val($("#slider-2").slider("values",0)); $("input#maxPrice").val($("#slider-2").slider("values",1)); }, superslide: function(event, ui1){ $("input#minPrice").val($("#slider-2").slider("values",0)); $("input#maxPrice").val($("#slider-2").slider("values",1)); } }); $("input#minPrice").change(function(){ var value1=$("input#minPrice").val(); var value2=$("input#maxPrice").val(); if (value1 < '.$minPrice.') { value1 = '.$minPrice.'; $("input#minPrice").val('.$minPrice.')} if(parseInt(value1) > parseInt(value2)){ value1 = value2; $("input#minPrice").val(value1); } $("#slider-2").slider("values",0,value1); }); $("input#maxPrice").change(function(){ var value1=$("input#minPrice").val(); var value2=$("input#maxPrice").val(); if (value2 > '.$maxPrice.') { value2 = '.$maxPrice.'; $("input#maxPrice").val('.$maxPrice.')} if(parseInt(value1) > parseInt(value2)){ value2 = value1; $("input#maxPrice").val(value2); } $("#slider-2").slider("values",1,value2); }); /* слайдер площади */ $("#slider-1").slider({ min: '.$minS.', max: '.$maxS.', values: ['.(isset($this->siarchparam['minS'])? $this->siarchparam['minS']:$minS).','.(isset($this->siarchparam['maxS'])? $this->siarchparam['maxS']:$maxS).'], range: true, stop: function(event, ui1) { $("input#minS").val($("#slider-1").slider("values",0)); $("input#maxS").val($("#slider-1").slider("values",1)); }, superslide: function(event, ui1){ $("input#minS").val($("#slider-1").slider("values",0)); $("input#maxS").val($("#slider-1").slider("values",1)); } }); $("input#minS").change(function(){ var value1=$("input#minS").val(); var value2=$("input#maxS").val(); if (value1 < '.$minS.') { value1 = '.$minS.'; $("input#minS").val('.$minS.')} if(parseInt(value1) > parseInt(value2)){ value1 = value2; $("input#minS").val(value1); } $("#slider-1").slider("values",0,value1); }); $("input#maxS").change(function(){ var value1=$("input#minS").val(); var value2=$("input#maxS").val(); if (value2 > '.$maxS.') { value2 = '.$maxS.'; $("input#maxS").val('.$maxS.')} if(parseInt(value1) > parseInt(value2)){ value2 = value1; $("input#maxS").val(value2); } $("#slider-1").slider("values",1,value2); }); // фильтрация ввода в поля $("input").keypress(function(event){ var key, keyChar; if(!event) var event = window.event; if (event.keyCode) key = event.keyCode; else if(event.which) key = event.which; if(key==null || key==0 || key==8 || key==13 || key==9 || key==46 || key==37 || key==39 ) return true; keyChar=String.fromCharCode(key); if(!/\d/.test(keyChar)) return false; }); // уборка лишних чекбоксов if (!$("#Garazh1").get(0).checked && !$("#Garazh2").get(0).checked) { $("#Garazh0").get(0).checked = true; } if (!$("#bass1").get(0).checked && !$("#bass2").get(0).checked) { $("#bass0").get(0).checked = true; } $("#etazh1").click(function () { if ($("#etazh1").get(0).checked && $("#etazh2").get(0).checked && $("#etazh3").get(0).checked) { $("#etazh2").get(0).checked = false; $("#etazh3").get(0).checked = false; } }); $("#etazh2").click(function () { if ($("#etazh1").get(0).checked && $("#etazh2").get(0).checked && $("#etazh3").get(0).checked) { $("#etazh1").get(0).checked = false; $("#etazh3").get(0).checked = false; } }); $("#etazh3").click(function () { if ($("#etazh1").get(0).checked && $("#etazh2").get(0).checked && $("#etazh3").get(0).checked) { $("#etazh1").get(0).checked = false; $("#etazh2").get(0).checked = false; } }); $("#typDom1").click(function () { if ($("#typDom1").get(0).checked && $("#typDom2").get(0).checked) { $("#typDom2").get(0).checked = false; } }); $("#typDom2").click(function () { if ($("#typDom1").get(0).checked && $("#typDom2").get(0).checked) { $("#typDom1").get(0).checked = false; } }); $("#Garazh1").click(function () { if ($("#Garazh1").get(0).checked && $("#Garazh2").get(0).checked) { $("#Garazh2").get(0).checked = false; $("#Garazh0").get(0).checked = false; } }); $("#Garazh2").click(function () { if ($("#Garazh1").get(0).checked && $("#Garazh2").get(0).checked) { $("#Garazh1").get(0).checked = false; $("#Garazh0").get(0).checked = false; } }); $("#Garazh0").click(function () { if ($("#Garazh0").get(0).checked) { $("#Garazh1").get(0).checked = false; $("#Garazh2").get(0).checked = false; } }); $("#Garazh1, #Garazh2").click(function () { if ($("#Garazh1").get(0).checked || $("#Garazh2").get(0).checked) { $("#Garazh0").get(0).checked = false; } if (!$("#Garazh1").get(0).checked && !$("#Garazh2").get(0).checked) { $("#Garazh0").get(0).checked = true; } }); $("#bass1").click(function () { if ($("#bass1").get(0).checked && $("#bass2").get(0).checked) { $("#bass2").get(0).checked = false; $("#bass0").get(0).checked = false; } }); $("#bass2").click(function () { if ($("#bass1").get(0).checked && $("#bass2").get(0).checked) { $("#bass1").get(0).checked = false; $("#bass0").get(0).checked = false; } }); $("#bass0").click(function () { if ($("#bass0").get(0).checked) { $("#bass1").get(0).checked = false; $("#bass2").get(0).checked = false; } }); $("#bass1, #bass2").click(function () { if ($("#bass1").get(0).checked || $("#bass2").get(0).checked) { $("#bass0").get(0).checked = false; } if (!$("#bass1").get(0).checked && !$("#bass2").get(0).checked) { $("#bass0").get(0).checked = true; } }); }); '; $this->document->addScriptDeclaration($script); //dump ($this->items,'$this->items'); ?> <div class="category-list<?php echo $this->pageclass_sfx;?>"> <?php if ($this->params->get('show_page_heading', 1)) : ?> <h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1> <?php endif; ?> <?php if ($this->params->get('show_category_title', 1) or $this->params->get('page_subheading')) : ?> <h2> <?php echo $this->escape($this->params->get('page_subheading')); ?> <?php if ($this->params->get('show_category_title')) : ?> <span class="subheading-category"><?php echo $this->category->title;?></span> <?php endif; ?> </h2> <?php endif; ?> <?php if ($this->params->get('show_description', 1) || $this->params->def('show_description_image', 1)) : ?> <div class="category-desc"> <?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?> <img src="/<?php echo $this->category->getParams()->get('image'); ?>"/> <?php endif; ?> <?php if ($this->params->get('show_description') && $this->category->description) : ?> <?php echo JHtml::_('content.prepare', $this->category->description, '', 'com_content.category'); ?> <?php endif; ?> <div class="clr"></div> </div> <?php endif; ?> <div class="filters_cover"> <div class="filters"> <form action="" method="post"> <table width="100%"> <tr> <td class="tabcell"> <table border="0" cellpadding="0" cellspacing="0" class="tab2"> <tr> <td class="name" colspan="4"> <b>Поиск по параметрам коттеджей: </b> </td> </tr> <tr> <td> <b>Материал стен:</b> </td> <td> <input id="typDom1" name="typDom[]" type="checkbox" value="kam" <?php echo isset($typDom['kam'])?' checked="checked" ':'' ?>/> <label for="typDom">Камень </label> </td> <td> <input id="typDom2" name="typDom[]" type="checkbox" value="der" <?php echo isset($typDom['der'])?' checked="checked" ':'' ?>/> <label for="typDom">Дерево </label> </td> <td> </td> </tr> <tr> <td> <b>Этажность:</b> </td> <td> <input id="etazh1" name="etazh[]" type="checkbox" value="1" <?php echo isset($etazh[1])?' checked="checked" ':'' ?>/> <label for="etazh">1 этаж</label> </td> <td> <input id="etazh2" name="etazh[]" type="checkbox" value="2" <?php echo isset($etazh[2])?' checked="checked" ':'' ?>/> <label for="etazh">2 этажа</label> </td> <td> <input id="etazh3" name="etazh[]" type="checkbox" value="3" <?php echo isset($etazh[3])?' checked="checked" ':'' ?>/> <label for="etazh">3 этажа: </label> </td> </tr> </table> </td> <td class="tabcell2"> <b>Наличие гаража:</b><br /> <input id="Garazh1" name="Garazh[]" type="checkbox" value="1" <?php echo isset($Garazh[1])?' checked="checked" ':'' ?>/> <label for="Garazh">Да</label> <input id="Garazh2" name="Garazh[]" type="checkbox" value="0" <?php echo isset($Garazh[0])?' checked="checked" ':'' ?>/> <label for="Garazh">Нет</label><br /> <input id="Garazh0" type="checkbox" value="0" /> <label for="Garazh">Не важно</label> </td> <td class="tabcell2"> <b>Наличие бассейна:</b><br /> <input id="bass1" name="bass[]" type="checkbox" value="1" <?php echo isset($bass[1])?' checked="checked" ':'' ?>/> <label for="bass">Да</label> <input id="bass2" name="bass[]" type="checkbox" value="0" <?php echo isset($bass[0])?' checked="checked" ':'' ?>/> <label for="bass">Нет</label><br /> <input id="bass0" type="checkbox" value="0" /> <label for="Garazh">Не важно</label> </td> </tr> </table> <table width="100%"> <tr> <td class="tabcell"> <div class="formCost"> <label for="minS"><b>Общая площадь: </b></label> от <input id="minS" name="minS" value="<?php echo isset($this->siarchparam['minS'])? $this->siarchparam['minS']:$minS; ?>" type="text"> <label for="maxS"> до </label> <input id="maxS" name="maxS" value="<?php echo isset($this->siarchparam['maxS'])? $this->siarchparam['maxS']:$maxS; ?>" type="text"> кв.м. </div> <div class="sliderCont1"> <div id="slider-1"></div> </div> <div class="formCost"> <label for="minPrice"><b>Цена: </b></label> от <input id="minPrice" name="minPrice" value="<?php echo isset($this->siarchparam['minPrice'])? $this->siarchparam['minPrice']:$minPrice; ?>" type="text"> <label for="maxPrice"> до </label> <input id="maxPrice" name="maxPrice" value="<?php echo isset($this->siarchparam['maxPrice'])? $this->siarchparam['maxPrice']:$maxPrice; ?>" type="text"> Руб. </div> <div class="sliderCont1"> <div id="slider-2"></div> </div> </td> <td class="tabcell"> <input type="submit" class="button finder" value="Подобрать"/> <input type="hidden" name="project_param" value="kotedje"/> </td> </tr> </table> </form> </div> </div> <div class="clear"></div> <div class="cat-items"> <?php echo $this->loadTemplate('articles'); ?> </div> <?php if (!empty($this->children[$this->category->id])&& $this->maxLevel != 0) : ?> <div class="cat-children"> <h3> <?php echo JTEXT::_('JGLOBAL_SUBCATEGORIES'); ?> </h3> <?php echo $this->loadTemplate('children'); ?> </div> <?php endif; ?> </div>
catalogkotedg_articles.php
<?php /** * @package Joomla.Site * @subpackage com_content * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // no direct access defined('_JEXEC') or die; JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); JHtml::_('behavior.tooltip'); JHtml::core(); // Create some shortcuts. $params = &$this->item->params; $n = count($this->items); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?> <?php if (empty($this->items)) : ?> <?php if ($this->params->get('show_no_articles', 1)) : ?> <p><?php echo JText::_('COM_CONTENT_NO_ARTICLES'); ?></p> <?php endif; ?> <?php else : ?> <form action="<?php echo htmlspecialchars(JFactory::getURI()->toString()); ?>" method="post" name="adminForm" id="adminForm"> <?php if(isset($this->siarchparam['project_param'])) { echo '<input type="hidden" name="project_param" value="kotedje"/>'; $this->pagination->setAdditionalUrlParam("project_param","kotedje"); echo '<input type="hidden" name="minS" value="'.$this->siarchparam['minS'].'"/>'; $this->pagination->setAdditionalUrlParam("minS",$this->siarchparam['minS']); echo '<input type="hidden" name="maxS" value="'.$this->siarchparam['maxS'].'"/>'; $this->pagination->setAdditionalUrlParam("maxS",$this->siarchparam['maxS']); echo '<input type="hidden" name="minPrice" value="'.$this->siarchparam['minPrice'].'"/>'; $this->pagination->setAdditionalUrlParam("minPrice",$this->siarchparam['minPrice']); echo '<input type="hidden" name="maxPrice" value="'.$this->siarchparam['maxPrice'].'"/>'; $this->pagination->setAdditionalUrlParam("maxPrice",$this->siarchparam['maxPrice']); if (isset($this->siarchparam['typDom'])) foreach ($this->siarchparam['typDom'] as $kay => $a) echo '<input type="hidden" name="typDom[]" value="'.$a.'"/>'; $this->pagination->setAdditionalUrlParam("typDom[$kay]",$a); if (isset($this->siarchparam['Garazh'])) foreach ($this->siarchparam['Garazh'] as $kay => $a) echo '<input type="hidden" name="Garazh[]" value="'.$a.'"/>'; $this->pagination->setAdditionalUrlParam("Garazh[$kay]",$a); if (isset($this->siarchparam['bass'])) foreach ($this->siarchparam['bass'] as $kay => $a) echo '<input type="hidden" name="bass[]" value="'.$a.'"/>'; $this->pagination->setAdditionalUrlParam("bass[$kay]",$a); if (isset($this->siarchparam['etazh'])) foreach ($this->siarchparam['etazh'] as $kay => $a) echo '<input type="hidden" name="etazh[]" value="'.$a.'"/>'; $this->pagination->setAdditionalUrlParam("etazh[$kay]",$a); } ?> <?php if ($this->params->get('show_headings') || $this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) :?> <fieldset class="filters"> <?php if ($this->params->get('filter_field') != 'hide') :?> <legend class="hidelabeltxt"> <?php echo JText::_('JGLOBAL_FILTER_LABEL'); ?> </legend> <div class="filter-search"> <label class="filter-search-lbl" for="filter-search"><?php echo JText::_('COM_CONTENT_'.$this->params->get('filter_field').'_FILTER_LABEL').' '; ?></label> <input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->state->get('list.filter')); ?>" class="inputbox" onchange="document.adminForm.submit();" title="<?php echo JText::_('COM_CONTENT_FILTER_SEARCH_DESC'); ?>" /> </div> <?php endif; ?> <?php if ($this->params->get('show_pagination_limit')) : ?> <div class="display-limit"> <?php echo JText::_('JGLOBAL_DISPLAY_NUM'); ?>  <?php echo $this->pagination->getLimitBox(); ?> </div> <?php endif; ?> <!-- @TODO add hidden inputs --> <input type="hidden" name="filter_order" value="" /> <input type="hidden" name="filter_order_Dir" value="" /> <input type="hidden" name="limitstart" value="" /> </fieldset> <?php endif; ?> <div class="category"> <?php foreach ($this->items as $i => $article) : ?> <?php // подготовка данных для элемента представления проекта в списке $article->images = json_decode($article->images); $pathToImage = JURI::root(TRUE).$article->images->image_intro; switch ($article->Etazh) { case 1: $article->Etazh = '1 этаж. '; break; case 2: $article->Etazh = '2 этажа. '; break; case 3: $article->Etazh = '3 этажа. '; }; ?> <div class="cat-list row<?php// echo $i % 2; ?>" > <table cellpadding="0" cellspacing="0"> <tr> <td class="title" align="center" colspan="2"> <a href="/<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid)); ?>"> <?php echo $this->escape($article->title); ?></a> </td> </tr> <tr> <td class="image" align="center" valign="middle" colspan="2"> <a href="/<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid)); ?>"> <img src="/<?php echo $pathToImage; ?>" alt="<?php echo $this->escape($article->title); ?>"/></a> </td> </tr> <?php echo '<tr class="str"><td class="td1">Общая площадь:</td><td class="td2">'.number_format($article->sObsh,2,',',' '). ' кв. м.</td></tr>'. '<tr class="str"><td class="td1">Этажность:</td><td class="td2">'.$article->Etazh.'</td></tr>'. '<tr class="str"><td class="td1">Стоимость:</td><td class="td2">'.number_format($article->price,0,'',' '). ' руб.</td></tr>';?> </table> <div class="readmore"> <a href="/<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid)); ?>"> подробнее... </a> </div> </div> <?php endforeach; ?> </div> <?php endif; ?> <?php // Code to add a link to submit an article. ?> <?php if ($this->category->getParams()->get('access-create')) : ?> <?php echo JHtml::_('icon.create', $this->category, $this->category->params); ?> <?php endif; ?> <?php // Add pagination links ?> <?php if (!empty($this->items)) : ?> <?php if (($this->params->def('show_pagination', 2) == 1 || ($this->params->get('show_pagination') == 2)) && ($this->pagination->get('pages.total') > 1)) : ?> <div class="pagination_cover"> <div class="pagination"> <?php if ($this->params->def('show_pagination_results', 1)) : ?> <p class="counter"> <?php echo $this->pagination->getPagesCounter(); ?> </p> <?php endif; ?> <?php echo $this->pagination->getPagesLinks(); ?> </div> </div> <?php endif; ?> </form> <?php endif; ?>
Чтобы при переходе на следующую страницу параметры фильтрации не сбрасывались, их надо передать в форму пагинации в виде скрытых параметров.