Django-cms干草堆搜索-占位符内容 [英] Django-cms haystack search - placeholder content

查看:84
本文介绍了Django-cms干草堆搜索-占位符内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在django-cms和haystack搜索中的结果有问题。我正在使用django-cms-search插件haystack作为后端。干草堆返回正确的结果。但是我想在搜索结果中显示筋急转弯。

i have problem with results in django-cms and haystack search. I'm using django-cms-search plugin, haystack as backend. Haystack returns correct results. But i want to show "teaser" in search results.

我可以通过以下方式通过模板访问绝对URL和页面标题:

I can access absolute URL and title of page via template this way:

{% for result in page.object_list %}
<div class="searchResults">
<h2>{{ result.object.get_title }}</h2>
{{ result.object.placeholders.all }}           
<p><a href="{{ result.object.get_absolute_url }}">{% blocktrans %} Read more {% endblocktrans %}</a></p>

问题部分是 {{result.object.placeholders.all}} 。我在每个页面上的内容中都包含带名称内容的占位符。

Problematic part is {{ result.object.placeholders.all }}. I have on every page content in placeholder with name content.

{{result.object.placeholders.all}} 仅返回占位符的名称。

{{ result.object.placeholders.all }} returns only name of the placeholders.

搜索结果应如下所示:

PAGE TITLE

PAGE TITLE

页面试用版

阅读更多链接

在预告片中应该是搜索匹配页面中的前50个字。

In teaser there should be first 50 words from search-matched page.

是否可以从模板访问占位符内容?

Is this possible to access placeholder content from template?

谢谢您的提示。

推荐答案

Haystack具有templatetag高光,它可以按我的要求创建筋急转弯。

Haystack has templatetag higlight which creates "teaser" as i requested.

模板代码如下所示:

{{ result.object.get_title }}
{% highlight result.text with request.GET.q max_lenght 40 %}
{{ result.object.get_absolute_url }}

感谢#haystack IRC频道的人员。

Thanks to guys from #haystack IRC channel.

这篇关于Django-cms干草堆搜索-占位符内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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