0 Пользователей и 1 Гость просматривают эту тему.
  • 10 Ответов
  • 6753 Просмотров
*

kontrast

  • Захожу иногда
  • 122
  • 2 / 0
делаю один сайт где надо чтоб структура вывода категорий и материалов была такой

название категории
дескрипшн категории
материалы категории

подкатегория 1
текст подкатегрии1
материалы подкатегории 1

подкатегория 2
текст подкатегрии 2
материалы подкатегории 2

...

но разбирая category.php
вижу что там итемы все сбиты в 1 кучу

вопрос
как достать материалы только для определенной категории (подкатегории)

был бы очень признательный за пример кода
*

staticlight

  • Moderator
  • 1086
  • 65 / 0
  • Staticlight
В настройках подкатегории - режим каталога - ДА
Руководитель отдела сервисного обслуживания систем безопасности.
Устали от com_content - поставьте com_k2.
TRIPLE "F" POWER: Firefox+FireShot+Firebug. Chrome + Ctrl+Shift+I
*

kontrast

  • Захожу иногда
  • 122
  • 2 / 0
В настройках подкатегории - режим каталога - ДА
это делает все материалы под всеми подкатегориями
а мне надо чтоб материалы категории были над подкатегориями
а материалы подкатегории под подкатегорией
*

staticlight

  • Moderator
  • 1086
  • 65 / 0
  • Staticlight
Надо править шаблон вывода category.php
Руководитель отдела сервисного обслуживания систем безопасности.
Устали от com_content - поставьте com_k2.
TRIPLE "F" POWER: Firefox+FireShot+Firebug. Chrome + Ctrl+Shift+I
*

kontrast

  • Захожу иногда
  • 122
  • 2 / 0
Надо править шаблон вывода category.php
ну это я понял
я даже нашол место где его править
только вот как изменить этот код на код который бы доставал итемы определенной категории(подкатегории) я незнаю
Код
<?php if((isset($this->leading) || isset($this->primary) || isset($this->secondary) || isset($this->links)) && (count($this->leading) || count($this->primary) || count($this->secondary) || count($this->links))): ?>
<!-- Item list -->
<div class="itemList">

<?php if(isset($this->leading) && count($this->leading)): ?>
<!-- Leading items -->
<div id="itemListLeading">
<?php foreach($this->leading as $key=>$item): ?>

<?php
// Define a CSS class for the last container on each row
if( (($key+1)%($this->params->get('num_leading_columns'))==0) || count($this->leading)<$this->params->get('num_leading_columns') )
$lastContainer= ' itemContainerLast';
else
$lastContainer='';
?>

<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->leading)==1)? '' : ' style="width:'.number_format(100/$this->params->get('num_leading_columns'), 1).'%;"'; ?>>
<?php
// Load category_item.php by default
$this->item=$item;
echo $this->loadTemplate('item');
?>
</div>
<?php if(($key+1)%($this->params->get('num_leading_columns'))==0): ?>
<div class="clr"></div>
<?php endif; ?>
<?php endforeach; ?>
<div class="clr"></div>
</div>
<?php endif; ?>

<?php if(isset($this->primary) && count($this->primary)): ?>
<!-- Primary items -->
<div id="itemListPrimary">
<?php foreach($this->primary as $key=>$item): ?>

<?php
// Define a CSS class for the last container on each row
if( (($key+1)%($this->params->get('num_primary_columns'))==0) || count($this->primary)<$this->params->get('num_primary_columns') )
$lastContainer= ' itemContainerLast';
else
$lastContainer='';
?>

<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->primary)==1)? '' : ' style="width:'.number_format(100/$this->params->get('num_primary_columns'), 1).'%;"'; ?>>
<?php
// Load category_item.php by default
$this->item=$item;
echo $this->loadTemplate('item');
?>
</div>
<?php if(($key+1)%($this->params->get('num_primary_columns'))==0): ?>
<div class="clr"></div>
<?php endif; ?>
<?php endforeach; ?>
<div class="clr"></div>
</div>
<?php endif; ?>

<?php if(isset($this->secondary) && count($this->secondary)): ?>
<!-- Secondary items -->
<div id="itemListSecondary">
<?php foreach($this->secondary as $key=>$item): ?>

<?php
// Define a CSS class for the last container on each row
if( (($key+1)%($this->params->get('num_secondary_columns'))==0) || count($this->secondary)<$this->params->get('num_secondary_columns') )
$lastContainer= ' itemContainerLast';
else
$lastContainer='';
?>

<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->secondary)==1)? '' : ' style="width:'.number_format(100/$this->params->get('num_secondary_columns'), 1).'%;"'; ?>>
<?php
// Load category_item.php by default
$this->item=$item;
echo $this->loadTemplate('item');
?>
</div>
<?php if(($key+1)%($this->params->get('num_secondary_columns'))==0): ?>
<div class="clr"></div>
<?php endif; ?>
<?php endforeach; ?>
<div class="clr"></div>
</div>
<?php endif; ?>

<?php if(isset($this->links) && count($this->links)): ?>
<!-- Link items -->
<div id="itemListLinks">
<h4><?php echo JText::_('K2_MORE'); ?></h4>
<?php foreach($this->links as $key=>$item): ?>

<?php
// Define a CSS class for the last container on each row
if( (($key+1)%($this->params->get('num_links_columns'))==0) || count($this->links)<$this->params->get('num_links_columns') )
$lastContainer= ' itemContainerLast';
else
$lastContainer='';
?>

<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->links)==1)? '' : ' style="width:'.number_format(100/$this->params->get('num_links_columns'), 1).'%;"'; ?>>
<?php
// Load category_item_links.php by default
$this->item=$item;
echo $this->loadTemplate('item_links');
?>
</div>
<?php if(($key+1)%($this->params->get('num_links_columns'))==0): ?>
<div class="clr"></div>
<?php endif; ?>
<?php endforeach; ?>
<div class="clr"></div>
</div>
<?php endif; ?>

</div>


<?php endif; ?>
*

red5

  • Осваиваюсь на форуме
  • 25
  • 2 / 0
тема до сих пор актуальна, полмира перерыл - не нашел, как выводить категории с подкатегориями.
*

alexmay

  • Осваиваюсь на форуме
  • 33
  • 0 / 0
Поскольку тема достаточно актуальна смотрим тут: http://joomlaforum.ru/index.php/topic,218661.msg1362269.html#msg1362269
*

jurassik

  • Давно я тут
  • 689
  • 52 / 1
название категории
description категории
материалы категории
Код
	$html = array();
foreach($this->leading as $item):
$this->item=$item;

if(!$html[$this->item->category->id])
$html[$this->item->category->id] = $this->item->category->name.'<br>'.$this->item->category->description;

$html[$this->item->category->id] .= $this->loadTemplate('item');

endforeach;

foreach ($html as $h)
echo $h;

сам шучу - сам смеюсь
*

sibay70

  • Осваиваюсь на форуме
  • 21
  • 6 / 0
Код
	$html = array();
foreach($this->leading as $item):
$this->item=$item;

if(!$html[$this->item->category->id])
$html[$this->item->category->id] = $this->item->category->name.'<br>'.$this->item->category->description;

$html[$this->item->category->id] .= $this->loadTemplate('item');

endforeach;

foreach ($html as $h)
echo $h;


Спасибо дружище, шикарное решение!  :D И что самое главное для меня - пагинация работает. Плюсую с удовольствием!
*

claripuci

  • Осваиваюсь на форуме
  • 20
  • 1 / 0
А вот как бы изображение ещё выводить с описанием подкатегории?
« Последнее редактирование: 06.11.2014, 15:26:01 от claripuci »
*

claripuci

  • Осваиваюсь на форуме
  • 20
  • 1 / 0
А вот как

Код
<?php $html = array();			
        foreach($this->leading as $item):
     $this->item=$item;
     if(!$html[$this->item->category->id])
     $html[$this->item->category->id] = '<img src=media/k2/categories/'.$this->item->category->image.' />'.$this->item->category->name.'<br>'.$this->item->category->description;
     $html[$this->item->category->id] .= $this->loadTemplate('item');
                 endforeach;
   
        foreach ($html as $h)
  echo $h; ?>

В PHP ничо не соображаю и, может быть, это я костыль приделал и неправильно, но работает. Может и пригодится кому.
« Последнее редактирование: 06.11.2014, 20:03:05 от claripuci »
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться