如何在搜索结果中显示CCK字段? [英] How to show CCK field in search result?

查看:138
本文介绍了如何在搜索结果中显示CCK字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Drupal核心搜索结果页面显示定制CCK字段(文本或ImageField的)?

How to display custom CCK field (text or imagefield) in Drupal core search results page?

推荐答案

您需要重写search-result-tpl.php在你的主题。将其从modules / search复制到您的主题目录,清除主题缓存,并设置好。您将看到有一个名为result的主题文件可用的数组,它包含一堆数据,包括一个节点对象。所以,你的文件成为这样的:

You need to override search-result-tpl.php in your theme. Copy it from modules/search to your themes directory, clear the theme cache, and you're set. You'll see that there is an array available to the theme file called 'result', which contains a bunch of data, including a node object. So your file becomes something like:

<dt class="title">
  <a href="<?php print $url; ?>"><?php print $title; ?></a>
</dt>
<dd>
<?php
 // Here is the change
 print $result['node']->field_name_of_cck_field['view'];
 ?>
  <?php if ($snippet) : ?>
    <p class="search-snippet"><?php print $snippet; ?></p>
  <?php endif; ?>
  <?php if ($info) : ?>
  <p class="search-info"><?php print $info; ?></p>
  <?php endif; ?>
</dd>



祝你好运!

Good luck!

这篇关于如何在搜索结果中显示CCK字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆