简体   繁体   中英

How mezzanine templating works?

I have a mezzanine website and in that website I am trying to show top stories block in the blog. I am able to show the recent posts but when I am trying to add something for top stories it is not working correctly. I don't have any clue of how to add this module. Any ideas? I am attaching the code for recent posts

<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>

Thanks in advance

I researched the whole day and found there is something like templatetags and you just have to add template tags to your app and with that you can create new tags and overwrite the older ones. for more information you can refer: https://docs.djangoproject.com/en/2.1/howto/custom-template-tags/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM