首页/开发手册/内容详情标签

开发手册

SoeayCMS 安装、标签使用与二次开发完整指南

内容详情标签

内容详情标签用于在详情页显示当前文章的所有信息。仅在内容详情页(content.html)中有效。

一、基本语法

{soeay:content.title}        内容标题
{soeay:content.subtitle}     副标题
{soeay:content.content}      正文内容
{soeay:content.ico}          缩略图
{soeay:content.date}         发布日期
{soeay:content.visits}       浏览量
{soeay:content.author}       作者
{soeay:content.source}       来源
{soeay:content.keywords}     关键词
{soeay:content.description}  描述
{soeay:content.filename}     自定义URL名
{soeay:content.outlink}      跳转链接

二、字段说明

字段说明
{soeay:content.title}内容标题
{soeay:content.subtitle}副标题
{soeay:content.content}正文(原始 HTML)
{soeay:content.ico}缩略图地址
{soeay:content.date}发布日期
{soeay:content.visits}浏览量
{soeay:content.author}作者
{soeay:content.source}来源
{soeay:content.keywords}关键词
{soeay:content.description}描述
{soeay:content.filename}自定义 URL 名
{soeay:content.outlink}跳转链接(外链时填写)
{soeay:content.sort_name}所属栏目名称
{soeay:content.sort_filename}所属栏目 URL 标识
{soeay:content.link}当前内容详情页链接(V2.0+ 支持)

三、日期格式化

日期字段支持 format 属性,使用 PHP date 格式字符:

{soeay:content.date format=Y-m-d}
{soeay:content.date format=Y年m月d日 H:i}

四、上一篇 / 下一篇

系统提供两种方式调用上一篇、下一篇,可按习惯任选。

方式一:单标签(推荐)

直接使用 {soeay:prev_content.*} / {soeay:next_content.*} 单标签输出对应字段。无记录时输出空字符串,配合 {soeay:if} 判断即可。

<div class="article-nav">
    <span class="prev">
        {soeay:if('{soeay:prev_content.title}'!='')}
            <a href="{soeay:prev_content.link}">上一篇:{soeay:prev_content.title}</a>
        {/soeay:if}
    </span>
    <span class="next">
        {soeay:if('{soeay:next_content.title}'!='')}
            <a href="{soeay:next_content.link}">下一篇:{soeay:next_content.title}</a>
        {/soeay:if}
    </span>
</div>
字段说明
{soeay:prev_content.title}上一篇标题
{soeay:prev_content.link}上一篇链接
{soeay:prev_content.ico}上一篇缩略图
{soeay:next_content.title}下一篇标题
{soeay:next_content.link}下一篇链接
{soeay:next_content.ico}下一篇缩略图

方式二:块标签

使用 {soeay:prev} 和 {soeay:next} 块标签循环输出。无对应记录时整体不输出。

{soeay:prev}
    <a href="[soeay:link]">上一篇:[soeay:title]</a>
{/soeay:prev}
{soeay:next}
    <a href="[soeay:link]">下一篇:[soeay:title]</a>
{/soeay:next}

块标签内可用字段:

字段说明
[soeay:title]标题
[soeay:link] / [soeay:url]详情页链接
[soeay:date]发布时间(可加 format=Y-m-d 格式化)
[soeay:ico]缩略图
[soeay:author]作者

五、相关内容

{soeay:related num=5}
    <a href="[soeay:link]">[soeay:title]</a>
{/soeay:related}

六、使用场景

  • 内容详情标签只在内容详情页(content.html)中有效。
  • 系统会自动将当前文章信息注入视图,模板中既可以用 {soeay:content.title} 等单标签直接输出,也可以结合 {soeay:content} 块标签(见「指定内容」章节)使用。

七、注意事项

  • {soeay:content.content} 输出的是富文本原始 HTML,如需在列表页做摘要,请使用 [soeay:content drophtml=1 len=100] 先去除标签再截取。
  • 浏览量 {soeay:content.visits} 默认不会在每次刷新时自动 +1,如需自增请在对应位置使用 [soeay:visits operate=+1](仅限块标签内)。
  • 上下篇按发布时间排序,且只取同栏目内的相邻记录。