wpgcms---詳情頁面資料怎麼渲染
阿新 • • 發佈:2018-11-08
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 %}