Django的== 1.5.1 的Django-CMS == 2.4.1Django的CMS“摘要视图”,从多个页面聚合内容
我想做出像所有的子页面的摘要视图在django-cms中选择一个页面,使用更多...链接为每个列出的孩子提取标题,截断内容等。我已经设法得到标题和路径,但我努力从占位符中获取内容。
我有这样的templatetag:
from cms.models import Page
from cms.utils.page_resolver import get_page_from_path
from django import template
register = template.Library()
@register.inclusion_tag('news_summary_item.html')
def get_news_items():
news_root = get_page_from_path('news')
newsitems = news_root.children.filter(published=True)
return {'newsitems':newsitems}
,这里是其使用的模板:
{% load cms_tags menu_tags %}
<ul>
{% for item in newsitems %}
<li><a href="/{{ item.get_path }}">{{ item.get_title }}</a>
{% for placeholder in item.placeholders.all %}
# {% show_placeholder placeholder.slot item current_language %} #
{% endfor %}
</li>
{% endfor %}
</ul>
任何人都可以在这里得到占位内容帮助吗?理想情况下,编号喜欢能够通过truncatewords_html传递给总结,但可以通过其他方式获得相同的效果。
感谢您的任何提示/指针!
对我的作品,一定要放在placeholder_tags在'{%负载.. 。%}'并在模板循环中使用“{%render_placeholder placeholder%}”。 – mkoistinen 2013-05-09 14:02:14
谢谢你。我需要做同样的事情,不知道从哪里开始! – Yablargo 2013-09-07 05:50:00