标签:oop get extend new view 调用 info 新闻 实例
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 %}
标签:oop get extend new view 调用 info 新闻 实例
原文地址:https://www.cnblogs.com/e0yu/p/9928409.html