На сайте drupalka.ru (не рекламирую, а ссылаюсь просто) нарыл полезную феньку.
Автор написал такую аннотацию: В этой статье рассмотрим возможности изменения средствами API Drupal`а стандартного вывода списка материалов отдельно взятого термина таксономии. Говоря другими словами, той страницы, что отображается у нас по адресу: taxonomy/term/id-термина.
<?phpfunction название темы_taxonomy_term_page($tids, $result)
{
drupal_add_css(drupal_get_path('module', 'taxonomy') .'/taxonomy.css');
$output = '<div id="category-item-list">';
// Only display the description if we have a single term, to avoid clutter and confusion.
if (count($tids) == 1) {
$term = taxonomy_get_term($tids[0]);
$description = $term->description;
// Check that a description is set.
if (!empty($description))
{
$output .= '<div class="taxonomy-term-description">';
$output .= filter_xss_admin($description);
$output .= '</div>';
}
}
$children_terms = taxonomy_get_children($term->tid);
if ($children_terms) {
$children_terms = taxonomy_get_children($term->tid);
foreach ($children_terms as $children_term )
{
$t_children_count = taxonomy_term_count_nodes($children_term->tid);
$children_items[] = l($children_term->name .' ('. $t_children_count .')','taxonomy/term/'. $children_term->tid, array('attributes' => array('title' => $children_term->name)));
}
$output .= theme('item_list', $children_items, t(''));
}
while ($node = db_fetch_object($result))
{
$items[] = l($node->title, 'node/'. $node->nid,array('attributes'=>array('title'=> $node->title)));
}
$output .= theme('item_list', $items, t(''), 'ul',array('class'=>'pub-list'));
$output .= theme('pager', NULL, variable_set('default_nodes_main', 20), 0);
$output .= '</div>';
return $output;
}?>
В принципе меня в этом коде всё устраивает. Но понадобилось сделать вывод не списка заголовков нод, принадлежащих термину, а списка кратких аннотаций нод.
Пробовал поковырять $items[] подставляя в $node teaser вместо title, но ничего не получилось.
Что неправильно делаю? Помогите.
Комментарии
вместо
$items[] = l($node->title, 'node/'. $node->nid,array('attributes'=>array('title'=> $node->title)));
нужно поставить
$items[] = node_view(node_load($node->nid), TRUE);
И если в списке 100 узлов, то будет работать 100 раз node_load... Тихий ужас.
Вообще задачу можно решить своим модулем, который одним запросом к базе будет вытягивать все узлы нужных терминов.
Нее, 100 узлов не будет.
Главное что решение работает.
Спасибо Юрий!
во views есть стандарная view, которая переопределяет вывод.
Path: taxonomy/term/%
Лента, Страница
A view to emulate Drupal core's handling of taxonomy/term; it also emulates Views 1's handling by having two possible feeds.