Помощь [Drupal 7] Темизация страницы тегов (решено)

puagardian

One Love
Регистрация
16 Июл 2012
Сообщения
436
Реакции
615
Есть страница со списком нод привязанных к термину (Для просмотра ссылки Войди или Зарегистрируйся), но выводятся там они совершенно ужасно и криво. Вопрос в том как настроить нормальный вывод, где в доках или еще где почитать по этому поводу? Или кратко как нормально все сделать опишите.
 
Все прописывается в стилях. Классы node node-aircraft node-navy node-teaser row-fluid post full и так далее.
 
Все прописывается в стилях. Классы node node-aircraft node-navy node-teaser row-fluid post full и так далее.
Вывод конкретных полей на странице тегов в стилях не прописывается. Вопрос абсолютно о другом.
 
Есть страница со списком нод привязанных к термину (Для просмотра ссылки Войди или Зарегистрируйся), но выводятся там они совершенно ужасно и криво. Вопрос в том как настроить нормальный вывод, где в доках или еще где почитать по этому поводу? Или кратко как нормально все сделать опишите.

Идешь в /modules/taxonomy/
Берешь там taxonomy-term.tpl.php

Запиливаешь его к себе в папку с шаблоном(templates) и темизируешь как тебе нужно.

taxonomy-term--[vocabulary-machine-name|tid].tpl.php
base template: taxonomy-term.tpl.php
Theme hook suggestions are made based on these factors, listed from the most specific template to the least. Drupal will use the most specific template it finds:

  1. taxonomy-term--tid.tpl.php
  2. taxonomy-term--vocabulary-machine-name.tpl.php
  3. taxonomy-term.tpl.php
Note that underscores in a vocabulary's machine name are replaced by hyphens.

Если не получиться, то запили в templates.php своего шаблона:

Код:
function ТВОЙШАБЛОН_preprocess_taxonomy_term(&$variables) {
  $variables['view_mode'] = $variables['elements']['#view_mode'];
  $variables['term'] = $variables['elements']['#term'];
  $term = $variables['term'];

  $uri = entity_uri('taxonomy_term', $term);
  $variables['term_url']  = url($uri['path'], $uri['options']);
  $variables['term_name'] = check_plain($term->name);
  $variables['page']      = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term);

  // Flatten the term object's member fields.
  $variables = array_merge((array) $term, $variables);

  // Helpful $content variable for templates.
  $variables['content'] = array();
  foreach (element_children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }

  // field_attach_preprocess() overwrites the $[field_name] variables with the
  // values of the field in the language that was selected for display, instead
  // of the raw values in $term->[field_name], which contain all values in all
  // languages.
  field_attach_preprocess('taxonomy_term', $term, $variables['content'], $variables);

  // Gather classes, and clean up name so there are no underscores.
  $vocabulary_name_css = str_replace('_', '-', $term->vocabulary_machine_name);
  $variables['classes_array'][] = 'vocabulary-' . $vocabulary_name_css;

  $variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->vocabulary_machine_name;
  $variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->tid;
}

П.С это я со своего templates.php взял, тут многое тебе не нужно, просто лень выпиливать, тут главное вот это:

// Gather classes, and clean up name so there are no underscores.
$vocabulary_name_css = str_replace('_', '-', $term->vocabulary_machine_name);
$variables['classes_array'][] = 'vocabulary-' . $vocabulary_name_css;

$variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->vocabulary_machine_name;
$variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->tid;

Я просто с этим не сталкивался, но примерно так должно быть
 
Пробовал одним и другим способом, пробовал указывать машинное имя и tid, чистил кэш но к той странице шаблон так и не привязался. Зато вываливается куча ошибок c указанием на ошибки в кастомных шаблонах нод:
Warning: Invalid argument supplied for foreach() in element_children() (line 6396 of /site.ru/includes/common.inc).
Warning: Cannot use a scalar value as an array in drupal_render() (line 5863 of /site.ru/includes/common.inc).
Warning: Cannot use a scalar value as an array in drupal_render() (line 5918 of /site.ru/includes/common.inc).
Notice: Undefined index: field_atags in include() (line 103 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Trying to get property of non-object in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Trying to get property of non-object in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Undefined index: field_sinfg in include() (line 118 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 121 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Trying to get property of non-object in include() (line 121 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 123 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Trying to get property of non-object in include() (line 123 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php).
Notice: Undefined index: field_ntag in include() (line 103 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Undefined index: field_sinfg in include() (line 118 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 121 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 121 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 123 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 123 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 121 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 121 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 123 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 123 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 121 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 121 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 123 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Trying to get property of non-object in include() (line 123 of /site.ru/sites/all/themes/mentor/templates/nodes/node--navy.tpl.php).
Notice: Undefined index: field_ltag in include() (line 103 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Trying to get property of non-object in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Trying to get property of non-object in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Trying to get property of non-object in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Trying to get property of non-object in include() (line 108 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Undefined index: taxonomy_term in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Trying to get property of non-object in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--land-systems.tpl.php).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /site.ru/modules/taxonomy/taxonomy.module).
Подозреваю что друпал именно их использует при выводе, вот только тут переменные нод не все доступны и валятся ошибки. На страницах самих нод все отлично работает.
 
ну так это нотисы же. что в строке 106 Notice: Undefined index: taxonomy_term in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php) и тд?
 
ну так это нотисы же. что в строке 106 Notice: Undefined index: taxonomy_term in include() (line 106 of /site.ru/sites/all/themes/mentor/templates/nodes/node--aircraft.tpl.php) и тд?
В файлах там все в порядке. Notice только на страницах "тегов" появляются.

И все же мне так и осталось непонятно. Как настроить вывод определенных полей нод на странице тега (Для просмотра ссылки Войди или Зарегистрируйся) сразу для всех терминов словаря, чтобы поля одинаково выводились на всех страницах терминов. Ну или хотя бы как так вывод полей нод настроить для каждого термина. Последняя загвоздка, а времени больше всего отнимает.


UPDATE: Решил настройкой через Panels и Views.
 
Последнее редактирование:
если все в порядке - нотисов не бывает. у вас php 5.3 как минимум. в 5.2 проверок на наличие не нужно было делать
 
если все в порядке - нотисов не бывает. у вас php 5.3 как минимум. в 5.2 проверок на наличие не нужно было делать
Вот когда вывод этих страниц настроил, то и нотисы исчезли. PHP 5.3
 
Назад
Сверху