我有一个自定义内容(使用cck),也就是field_thewittyshit,它有一个字段,也就是field。我想为所有的视图主题field_thewittyshit字段。我编写了以下代码,并将其保存在一个名为views-view-field--default--field-thewittyshit-value.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.
*/
?>
<em>
<?php print $output; ?>
<em/>我想格式化文本。在这段代码中,我只是让它以斜体显示。
发布于 2010-06-28 22:47:12
您要覆盖的模板必须位于您的主题目录中。在视图模块文件夹中找到views-view-field.tpl.php文件,并将其复制并粘贴到views-view-field--default--field-thewittyshit-value.tpl.php所在的主题目录中。这样你就可以使用这个文件了。执行此操作后,还要确保清除缓存。
出于调试的目的,如果您仍然有问题,请确保视图使用的是views-view-field--default--field-thewittyshit-value.tpl.php。在视图UI的“基本设置”部分下,单击主题选项旁边的“信息”。您使用的主题将以粗体显示。
https://stackoverflow.com/questions/3129839
复制相似问题