zoukankan      html  css  js  c++  java
  • 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 %}
  • 相关阅读:
    前端的一些小的效果
    数组排序
    查看字符串中出现次数最多的字符以及出现的次数
    让元素垂直水平居中的方式
    MySQL
    数组_集合转换
    Spring_使用(JDBC)
    Spring_Aop基于配置文件
    Spring_Aop_(二)
    Spring_总结
  • 原文地址:https://www.cnblogs.com/e0yu/p/9928409.html
Copyright © 2011-2022 走看看