在 Drupal-6 中设置字段主题

发布于 2024-09-07 10:04:37 字数 1156 浏览 6 评论 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/>

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

I have a custom content (using cck) namely thewittyshit and it has a field namely field_thewittyshit . I want to theme field_thewittyshit field for all the views. I wrote the following code and saved it in a new file namely views-view-field--default--field-thewittyshit-value.tpl.php . But still no change is reflected in any of my views or node display.

<?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/>

I want to format the text. In this code i am just making it appear in italics.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅笑依然 2024-09-14 10:04:37

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

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

The template you are overriding must reside in your theme directory. Find the views-view-field.tpl.php file in the views module folder and copy and paste it into your theme directory where your views-view-field--default--field-thewittyshit-value.tpl.php resides. This should let you then use this file. Also make sure to clear the cache after you do this.

For debugging purposes, if you are still having troubles, make sure views is using views-view-field--default--field-thewittyshit-value.tpl.php. Click on "information" next to the theme option in the views UI under the "Basic settings" section. The theme that you are using will be in bold.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文