wpgcms---详情页面数据怎么渲染

wpgcms的详情页面的数据会被保存在 contentInfo 这么一个字段里面。

面包屑导航调用:

<p>当前位置 
{% for c in crumb|slice(1, crumb|length-1) %}
    {% if not loop.last %}> 
    <a href="{{ c.url }}">{{ c.name }}</a>
    {% else %}>
    <span><a href="javascript:;">新闻详情</a></span>
    {% endif %}
{% endfor %}
</p>

标题,正文,时间的调用:

<h1>{{ contentInfo.title }}</h1>
<div>
    {% autoescape false %}
        {{ contentInfo.getBodyInfo() }}
    {% endautoescape %}
</div>
<div class="details-news-content-title-time">
    <span>
        {% set pubtime = contentInfo.publish_time %}
        <span>时间:{{ pubtime|slice(0, 4) }}年{{ pubtime|slice(5, 2) }}月{{ pubtime|slice(8, 2) }}日</span>
        <span>来源:{{ contentInfo.source_name|default('金塔集团') }}</span>
        <span>阅读:{{ contentInfo.view_count }}</span>
    </span>
</div>

下一篇,下一篇的调用:

<p class="next-article-p">
    {% set nextInfo = contentInfo.nextInfo %}
    {% if nextInfo %}
    <a href="{{ nextInfo.aurl }}"/>下一篇:{{ nextInfo.title }}</a>
    {% endif %}
</p>

完整实例:

{% extends 'layout.html' %}

{% block pageContent %}
<section>
    <div class="details-news">
        <div class="details-news-content">
            <p>当前位置 
            {% for c in crumb|slice(1, crumb|length-1) %}
                {% if not loop.last %}> 
                <a href="{{ c.url }}">{{ c.name }}</a>
                {% else %}>
                <span><a href="javascript:;">新闻详情</a></span>
            {% endif %}
            {% endfor %}
            </p>
            <div class="details-news-content-title">
                <h1>{{ contentInfo.title }}</h1>
                <div>
                    {% autoescape false %}
                        {{ contentInfo.getBodyInfo() }}
                    {% endautoescape %}
                </div>
                <div class="details-news-content-title-time">
                    <span>
                        {% set pubtime = contentInfo.publish_time %}
                        <span>时间:{{ pubtime|slice(0, 4) }}年{{ pubtime|slice(5, 2) }}月{{ pubtime|slice(8, 2) }}日</span>
                        <span>来源:{{ contentInfo.source_name|default('金塔集团') }}</span>
                        <span>阅读:{{ contentInfo.view_count }}</span>
                    </span>
                </div>    
                <div class="clear"></div>
                <p class="next-article-p">
                    {% set nextInfo = contentInfo.nextInfo %}
                    {% if nextInfo %}
                    <a href="{{ nextInfo.aurl }}"/>下一篇:{{ nextInfo.title }}</a>
                    {% endif %}
                </p>
            </div>
        </div>
    </div>
</section>
{% endblock %}

 

转载于:https://www.cnblogs.com/e0yu/p/9928409.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值