Drupal 7 在搜索结果中打印内容字段
我正在使用 drupal 7 和 apache solr...
我想在搜索结果中打印内容字段...听起来很简单,
我将此函数放置在自定义模块中:
function module_name_apachesolr_modify_query(&$query , &$params) { $query->params['fl'] .= ',im_field_name'; 我验证
了 /admin/reports/apachesolr 中的字段名称是否正确。我启用了该模块,到目前为止一切看起来都是正确的。
然后在 search-result.tpl.php 中,我做了几种变体
没有成功...我想我可能做了一些愚蠢的事情。我会继续努力,但非常感谢任何帮助!谢谢!
I'm using drupal 7, with apache solr...
I want to print a content field in the search results...Sounded easy enough,
I placed this function in a custom module:
function module_name_apachesolr_modify_query(&$query, &$params) {
$query->params['fl'] .= ',im_field_name';
}
I verified that the field name was correct in /admin/reports/apachesolr. I enabled the module, and everything so far looked correct.
Then in search-result.tpl.php I've done several variations of,
<?php print render($content['im_field_name']); ?>
With no success...I figured i might be doing something stupid. I'll keep plugging away at it, but any help is very appreciated! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目前正在学习这个,我一直在寻找同样的东西,但设法让它发挥作用。不幸的是,似乎没有太多关于 Drupal 7 的文档,但在The Definitive Guide to Drupal 7一书中有一个小章节。
我使用了 hook_apachesolr_query_alter(),例如:
添加上述内容意味着它现在在模板的预处理函数中可见,因此我执行了以下操作:
然后它可用于模板:
Currently learning this and I was looking for the same thing, but managed to get it working. Unfortunately, there doesn't seem to be much documentation around for Drupal 7, but there is a small chapter about it in The Definitive Guide to Drupal 7 book.
I used hook_apachesolr_query_alter(), for example:
Adding the above meant it was now visible in the preprocess function for the template, so I did the below:
Then it was available to the template:
对于那些想要自定义 Apache 显示搜索结果的方式的人,我强烈建议您查看 Display Suite 模块索尔。它提供了高级别的搜索页面定制,包括由 Apache Solr 生成的搜索页面。观看此截屏视频:
Drupal 7 的 Display Suite - 第 5 部分:搜索显示
I highly recommend checking out the Display Suite module, for those wanting to customize the way search results are displayed by Apache Solr. It provides a high level of customization of search pages, including those generated by Apache Solr. Check out this screencast:
Display Suite for Drupal 7 - Part 5: search display