Views переопределение вывода поля

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

Аватар пользователя teamfighter teamfighter 14 октября 2009 в 13:14

Вообщем, суть вопроса такая. Есть вьюха, работающая как поисковая форма. На выходе дает таблицу. (посмотреть можно тут: http://itblog.ath.cx:82/search ). Задача: поле field_furninure заставить в зависимости от значения показывать картинку. Значения два: "есть" и "нет". Создал шаблон views-view-table--search--default.tpl.php,положил в папку с темой, в него закинул вот такой код:

<?php
switch ($field) {
    case 
'field_furninure':
            switch (
$row[$field]) {
            case 
'есть':
                
$content '<img src="' base_path() . path_to_theme() . '/images/yes.gif" />';
                break;
            case 
'нет':
                
$content '<img src="' base_path() . path_to_theme() . '/images/no.gif" />';
                break;
            }
        break;
}
?><?php print $content?>

Не работает. В чем может быть проблема?

Комментарии

Аватар пользователя wazzup wazzup 14 октября 2009 в 14:23

views-view-field--sell-price.tpl.php

<?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
$data = $row->{$field->field_alias};
if ($data > 0 )
{
print $output;
}
else {
        print t('Call');
} ;

?>

примерно так