0

我有一个自定义内容(使用 cck),即 thewittyshit ,它有一个字段 field_thewittyshit 。我想为所有视图主题 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/>

我想格式化文本。在这段代码中,我只是让它以斜体显示。

4

1 回答 1

1

您要覆盖的模板必须位于您的主题目录中。在视图模块文件夹中找到该views-view-field.tpl.php文件,然后将其复制并粘贴到您views-view-field--default--field-thewittyshit-value.tpl.php所在的主题目录中。这应该让您可以使用该文件。还请确保在执行此操作后清除缓存。

出于调试目的,如果您仍然遇到问题,请确保视图正在使用views-view-field--default--field-thewittyshit-value.tpl.php. 单击“基本设置”部分下视图 UI 中主题选项旁边的“信息”。您正在使用的主题将以粗体显示。

于 2010-06-28T14:47:12.293 回答