Реализовал категорий в фильтре чекбоксами так. Подсмотрел у Cheren-dow
Открываем файл
сайт\media\zoo\applications\jbuniversal\config\mod_jbzoo_search\itemcategory.xml
И заменяем все содержимое на это
<?xml version="1.0" encoding="utf-8"?>
<!-- JBZoo App is universal Joomla CCK, application for YooTheme Zoo component @package jbzoo @version 2.x Pro @author JBZoo App http://jbzoo.com @copyright Copyright (C) JBZoo.com, All rights reserved. @license http://jbzoo.com/license-pro.php JBZoo Licence @coder Denis Smetannikov <denis@jbzoo.com>-->
<element>
<params group="render">
<param name="jbzoo_filter_render"
type="list"
label="JBZOO_ELEMENT_TEMPLATE"
description="JBZOO_ELEMENT_TEMPLATE_DESC"
default="_auto_"
>
<option value="_auto_">JBZOO_ELEMENT_TEMPLATE_AUTO</option>
<option value="category">JBZOO_ELEMENT_TEMPLATE_CATEGORIES</option>
<option value="category-chosen">JBZOO_ELEMENT_TEMPLATE_CATEGORIES_CHOSEN</option>
<option value="category-hidden">JBZOO_ELEMENT_TEMPLATE_CATEGORY_HIDDEN</option>
<option value="hidden">JBZOO_ELEMENT_TEMPLATE_HIDDEN</option>
<option value="checkbox">CheckBox</option>
</param>
<param name="jbzoo_filter_default"
type="text"
default=""
label="JBZOO_FILTER_DEFAULT"
description="JBZOO_FILTER_DEFAULT_DESC"
/>
<param name="jbzoo_category_mode"
type="list"
default="tree"
label="JBZOO_FILTER_CATEGORY_MODE"
description="JBZOO_FILTER_CATEGORY_MODE_DESC">
<option value="none">JBZOO_FILTER_NONE</option>
<option value="tree">JBZOO_FILTER_TREE</option>
<option value="parent">JBZOO_FILTER_ONLY_PARENT</option>
<option value="child">JBZOO_FILTER_ONLY_CHILD</option>
<option value="child_off_category">Дочерние категории указанной категории</option>
</param>
<param name="jbzoo_filter_multiple"
type="jbbool"
default="0"
label="JBZOO_FILTER_MULTIPLE"
description="JBZOO_FILTER_MULTIPLE_DESC"/>
<param name="jbzoo_filter_count"
type="jbbool"
default="1"
label="JBZOO_FILTER_COUNT"
description="JBZOO_FILTER_COUNT_DESC"/>
<param name="jbzoo_filter_placeholder"
type="text"
default=""
label="JBZOO_FILTER_PLACEHOLDER"
description="JBZOO_FILTER_PLACEHOLDER_DESC"
/>
<param name="@spacer"
type="jbspacer"
default="Дочерние категории указанной категории"/>
<param name="jbzoo_parent_category_id"
type="text"
default=""
label="Id родительской категории"
description=""/>
</params>
</element>
В следующем файле добавил
сайт.ru/media/zoo/applications/jbuniversal/framework/render/filter/element.category.php
<?php
/**
* JBZoo App is universal Joomla CCK, application for YooTheme Zoo component
*
* @package jbzoo
* @version 2.x Pro
* @author JBZoo App http://jbzoo.com
* @copyright Copyright (C) JBZoo.com, All rights reserved.
* @license http://jbzoo.com/license-pro.php JBZoo Licence
* @coder Denis Smetannikov <denis@jbzoo.com>
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
/**
* Class JBFilterElementCategory
*/
class JBFilterElementCategory extends JBFilterElement
{
/**
* Render HTML
* @return string
*/
function html()
{
$this->_isMultiple = true;
$values = $this->_getValues();
return $this->app->jbhtml->select(
$this->_createOptionsList($values),
$this->_getName(),
$this->_attrs,
$this->_value,
$this->_getId()
);
return $this->app->jbhtml->checkbox(
$this->_createOptionsList($values),
$this->_getName(''),
$this->_attrs,
$this->_value,
$this->_getId()
);
}
/**
* Get categories list
* @return array
*/
private function _getCategoriesList()
{
$applicationId = (int)$this->_params->get('item_application_id', 0);
$application = $this->app->table->application->get($applicationId);
$modeParam = $this->_params->get('jbzoo_category_mode', 'tree');
$allCategories = array();
if ($application) {
$allCategories = $application->getCategories(true);
}
$result = array();
if (empty($allCategories)) {
return $result;
}
if ($modeParam == 'parent') {
// only parents
foreach ($allCategories as $category) {
if (!$category->parent) {
$result[] = $category;
}
}
} elseif ($modeParam == 'child') {
// only childs
foreach ($allCategories as $category) {
if ($category->parent) {
$result[] = $category;
}
}
} elseif ($modeParam == 'tree') {
// tree view
$result = $this->app->tree->buildList(0, $this->app->tree->build($allCategories, 'Category'));
} else {
$result = $allCategories;
}
return $result;
}
/**
* Get categories list values
* @param null $type
* @return array
*/
protected function _getValues($type = null)
{
$catList = $this->_getCategoriesList();
$catValues = $this->_getDbValues();
$categoriesList = array();
foreach ($catList as $category) {
$found = false;
foreach ($catValues as $catValue) {
if ($catValue['value'] == $category->name) {
$category->countItems = $catValue['count'];
$categoriesList[] = $category;
$found = true;
break;
}
}
if (!$found) {
$category->countItems = 0;
$categoriesList[] = $category;
}
}
$modeParam = $this->_params->get('jbzoo_category_mode', 'tree');
$options = array();
foreach ($categoriesList as $category) {
if ($modeParam == 'tree') {
$options[] = array(
'value' => $category->id,
'text' => ' ' . $category->treename,
'count' => $this->_isCountShow ? $category->countItems : null,
);
} else {
$options[] = array(
'value' => $category->id,
'text' => $category->name,
'count' => $this->_isCountShow ? $category->countItems : null,
);
}
}
return $options;
}
/**
* @param $value
* @return mixed
*/
protected function _getElementValue($value)
{
if ($this->_isValueEmpty($value)) {
$value = $this->app->jbrequest->getSystem('category');
}
return parent::_getElementValue($value);
}
}
Получаем дополнительный шаблон с Чек-бокс.
Все вроде как хорошо но фильтрует не правильно.
Сообщение отредактировал grickov84: 29 October 2015 - 21:29