Read more в views

Главные вкладки

Аватар пользователя solomenikm solomenikm 19 января 2010 в 20:42

Сиуация следующая есть views->page в нем отображается node:teaser, node:link (read more), но отображается она везде даже там где как такового тела поста нет, а есть только заголовок. Вопрос таков: как сделать так чтоб отображалась только там где это нужно. Может кто-то сталкивался?

Комментарии

Аватар пользователя serious.vip@drupal.org serious.vip@dru... 20 января 2010 в 9:20

читаем внимательно про темизацию Views, а именно дефолтный шаблон для поля

<?php
// $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $
 /**
  * This template is used to print a single field in a view. It is not
  * actually used in default Views, as this is registered as a theme
  * function which has better performance. For single overrides, the
  * template is perfectly okay.
  *
  * Variables available:
  * - $view: The view object
  * - $field: The field handler object that can process the input
  * - $row: The raw SQL result that can be used
  * - $output: The processed output that will normally be used.
  *
  * When fetching output from the $row, this construct should be used:
  * $data = $row->{$field->field_alias}
  *
  * The above will guarantee that you'll always get the correct data,
  * regardless of any changes in the aliasing that might happen if
  * the view is modified.
  */

?>
<?php print $output; ?>

и заостряем внимание на строчке

$data = $row->{$field->field_alias}

в итоге - когда вы рендерите View, в шаблоне для read more, проверяете, не пусто ли поле teaser (через соответствующий field_alias естественно), и если не пусто - print $output
в настройках же поля устанавливаем - не выводить пустые

костыль конечно, но рабочий