Performance 如何正确设置Drupal 7中视图字段的主题

Performance 如何正确设置Drupal 7中视图字段的主题,performance,drupal,view,drupal-7,drupal-theming,Performance,Drupal,View,Drupal 7,Drupal Theming,我需要在Drupal7中创建主题视图。有一个内容类型“书”,我需要列出5本书,并以特殊的方式(预览图像,标题和作者)它们的主题 当我重写views-view-field.tpl.php并打印原始SQL结果时,我看到所有字段都显示出来。此代码 echo "<pre>"; print_r($row); echo "</pre>"; 但我不想将[body]从数据库传递到php端,因为它可能非常庞大,并导致性能问题。我没有在视图设置中选择[body] 有没有办法只将某些字段传递

我需要在Drupal7中创建主题视图。有一个内容类型“书”,我需要列出5本书,并以特殊的方式(预览图像,标题和作者)它们的主题

当我重写views-view-field.tpl.php并打印原始SQL结果时,我看到所有字段都显示出来。此代码

echo "<pre>";
print_r($row);
echo "</pre>";
但我不想将[body]从数据库传递到php端,因为它可能非常庞大,并导致性能问题。我没有在视图设置中选择[body]

有没有办法只将某些字段传递给views-view-field.tpl.php


提前感谢。

如果您想对某个字段进行主题化,您可以为该特定字段创建一个模板,如下所示:视图字段--字段名myfield.tpl.php将其放置在主题文件夹中,然后在视图配置的主题:信息部分重新扫描模板


为此,必须将字段添加到视图中的字段中。

要在主题中对信息进行排序,请使用以下方法:

<?php
//after enabling the devel module...
dpm($fields);

// This will print a Kuomo display on the page with the array's vars

?>
//查看视图中的所有信息

可用变量写在站点/all/modules/views/theme文件夹文件中的文档中

通常,在views-view-fields.tpl.php模板上需要查看和修改的变量是$fields

我使用devel模块(http://drupal.org/project/devel)要查看可用的变量,请执行以下操作:

<?php print $fields['title']->content; ?> 

如果要更改视图主题,请更改视图字段.tpl.php,如下所示:



您是在尝试为特定视图或一般视图设置主题?我需要为一个视图设置主题,该视图操作一种内容类型谢谢,这很有效。但我仍然担心表现。print_r($row)输出给定内容类型的所有字段,即使这些字段未在视图中选择。它们的结构是巨大的。我能禁用大部分吗?有趣的问题。对此不确定…我将尝试查找。请注意,您可以从视图的“编辑”页面的“高级”>“主题:信息”下获取可能的模板文件名。
<?php
//after enabling the devel module...
dpm($fields);

// This will print a Kuomo display on the page with the array's vars

?>
<?php print $fields['title']->content; ?> 
<?php print $fields['field_FIELDNAME']->content; ?>
<?php dpm(get_defined_vars()); ?>
<div class="pagecontent">
    <div class="colleft">
        <?php if($fields['field_file']->content){  ?><div class="views-field-file"><?php print $fields['field_file']->content; ?></div><?php } ?>
    </div>
    <div class="colright">
        <div class="views-field-title"><?php print $fields['title']->content; ?></div>
        <div class="views-field-body"><?php print $fields['body']->content; ?></div>
        <div class="views-field-view-node"><?php print $fields['view_node']->content; ?></div>
    </div>
</div>