Модифицируем com_search под выдачу результатов поиска в шаблон категории com_phocagallery.
В файле плагина в строке 135
. ' "2" AS browsernav, b.id as catid, b.alias as catalias'
ставим запятую после catalias и добавляем выборку названия файла и папки категории:
. ' "2" AS browsernav, b.id as catid, b.alias as catalias,'
. ' a.filename as filename, b.userfolder as userfolder'
В файле вида компонента поиска (/components/com_search/views/search/view.html.php) строчку
класса SearchViewSearch закомментируем:
Все что после нее - удаляем и добавляем следующий код:
if(! class_exists('PhocagalleryModelCategory')) {
require_once( JPATH_BASE.DS.'components'.DS.'com_phocagallery'.DS.'models'.DS.'category.php');
}
if (! class_exists('PhocaGalleryLoader')) {
require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocagallery'.DS.'libraries'.DS.'loader.php');
}
$model = new PhocagalleryModelCategory;
phocagalleryimport('phocagallery.image.image');
phocagalleryimport('phocagallery.library.library');
phocagalleryimport('phocagallery.render.renderinfo');
phocagalleryimport('phocagallery.file.file');
phocagalleryimport('phocagallery.render.renderfront');
phocagalleryimport('phocagallery.image.imagefront');
phocagalleryimport('phocagallery.text.text');
if (! class_exists('PhocaGalleryViewCategory')) {
require_once(JPATH_BASE.DS.'components'.DS.'com_phocagallery'.DS.'views'.DS.'category'.DS.'view.html.php');
//require_once(JPATH_BASE.DS.'components'.DS.'com_phocagallery'.DS.'views'.DS.'category'.DS.'tmpl'.DS.'default.php');
PhocaGalleryViewCategory::display();
}
//parent::display($tpl);
}
function _addBreadCrumbs($category, $rootId, $displayStyle)
{
global $mainframe;
$i = 0;
while (isset($category->id))
{
$crumbList[$i++] = $category;
if ($category->id == $rootId)
{
break;
}
$db =& JFactory::getDBO();
$query = 'SELECT *' .
' FROM #__phocagallery_categories AS c' .
' WHERE c.id = '.(int) $category->parent_id.
' AND c.published = 1';
$db->setQuery($query);
$rows = $db->loadObjectList('id');
if (!empty($rows))
{
$category = $rows[$category->parent_id];
}
else
{
$category = '';
}
// $category = $rows[$category->parent_id];
}
$pathway =& $mainframe->getPathway();
$pathWayItems = $pathway->getPathWay();
$lastItemIndex = count($pathWayItems) - 1;
for ($i--; $i >= 0; $i--)
{
// special handling of the root category
if ($crumbList[$i]->id == $rootId)
{
switch ($displayStyle)
{
case 0: // 0 - only menu link
// do nothing
break;
case 1: // 1 - menu link with category name
// replace the last item in the breadcrumb (menu link title) with the current value plus the category title
$pathway->setItemName($lastItemIndex, $pathWayItems[$lastItemIndex]->name . ' - ' . $crumbList[$i]->title);
break;
case 2: // 2 - only category name
// replace the last item in the breadcrumb (menu link title) with the category title
$pathway->setItemName($lastItemIndex, $crumbList[$i]->title);
break;
}
}
else
{
$pathway->addItem($crumbList[$i]->title, JRoute::_('index.php?option=com_phocagallery&view=category&id='. $crumbList[$i]->id.':'.$crumbList[$i]->alias.'&Itemid='. JRequest::getVar('Itemid', 0, '', 'int') ));
}
}
}
}
Отключаем статистику в phoca при поиске:
В файле /components/com_search/views/search/tmpl/view.html.php на 1693 строке заменяем
на
$option = JRequest::getVar('option');
if($option != 'com_search') {
$model->hit($id);
}
Так мы подключаем фреймворк и часть модели PhocaGallery в вид поиска. Далее нам следует модифицировать шаблон поиска.
Создаем файл /components/com_search/views/search/tmpl/default_phocagallery.php и копируем в него все из /components/com_phocagallery/views/category/tmpl/default.php
В файле /components/com_search/views/search/tmpl/default.php заменяем весь код на следующий:
<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php if ( $this->params->get( 'show_page_title', 1 ) ) : ?>
<div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo $this->params->get( 'page_title' ); ?>
</div>
<?php endif; ?>
<?php echo $this->loadTemplate('form'); ?>
<?php
if(!$this->error && count($this->results) > 0)
{
if(!empty($this->searchareas['active']) && in_array('phocagallery', $this->searchareas['active']))
{
echo $this->loadTemplate('phocagallery');
}
else
{
echo $this->loadTemplate('results');
}
}
else
{
echo $this->loadTemplate('error');
}
?>
В итоге получаем результаты поиска такими же как и обычная страница категории с фотографиями со всем javascript'ом и без потребности в верстке.