【发布时间】:2018-10-07 05:35:42
【问题描述】:
我有一个夹层网站,我试图在该网站中显示博客中的热门故事块。我可以显示最近的帖子,但是当我尝试为热门故事添加内容时,它无法正常工作。我不知道如何添加这个模块。有任何想法吗? 我附上最近帖子的代码
<div class="section_content">
<div class="grid clearfix">
<div>
{% load blog_tags keyword_tags mezzanine_tags i18n %}
{% blog_recent_posts 1 as recent_posts %}
{% if recent_posts %}
{% for recent_post in recent_posts %}
<div class="card card_largest_with_image grid-item">
{% spaceless %}
<a class="text-capitalize" href="{{ recent_post.get_absolute_url }}">
{% if settings.BLOG_USE_FEATURED_IMAGE and recent_post.featured_image %}
<img class="card-img-top" src="{{ MEDIA_URL }}{% thumbnail recent_post.featured_image 610 193 %}">
{% endif %}
</a>
{% endspaceless %}
<div class="card-body">
<div class="card-title"><a href="{{ recent_post.get_absolute_url }}">{{ recent_post.title }}</a></div>
<p class="card-text">{{ recent_post.description|safe }}</p>
<small class="post_meta"><span>{{ recent_post.publish_date|timesince }} {% trans "ago" %}</span></small>
</div>
</div>
{% endfor %}
{% endif %}
</div>
{% blog_recent_posts 5 as recent_posts %}
{% if recent_posts %}
{% for recent_post in recent_posts %}
<div class="card card_default card_small_with_background grid-item">
{% spaceless %}
<a class="text-capitalize" href="{{ recent_post.get_absolute_url }}">
{% if settings.BLOG_USE_FEATURED_IMAGE and recent_post.featured_image %}
<div class="card_background" style="background-image:url({{ MEDIA_URL }}{% thumbnail recent_post.featured_image 263 165 %}); height: 163px; width:265px;"></div>
{% endif %}
{% endspaceless %}
<div class="card-body">
<div class="card-title card-title-small"><a href="{{ recent_post.get_absolute_url }}">{{
recent_post.title }}</a></div>
<small class="post_meta"><span>{{ recent_post.publish_date|timesince }} {% trans "ago" %}</span></small>
</div>
</div>
{% endfor %}
{% endif %}
</div>
提前致谢
【问题讨论】: