TanzCMS开源CMS系统

常用变量

TanzCMS 官方文档示例,展示模板标签、开放 API、内容管理和部署说明。

更新:2026-05-30 20:08:03 浏览:3

全局变量与页面变量

全局变量

所有前台主题页面通常都能使用这些变量:

变量 说明
{$site.name} 站点名称。
{$site.url} 站点首页地址。
{$site.logo} 站点 Logo。
{$site.description} 站点描述。
{$site.icp} 备案号。
{$site.police_record} 公安备案号。
{$site.copyright} 版权信息。
{$seo.title} 当前页 SEO 标题。
{$seo.keywords} 当前页 SEO 关键词。
{$seo.description} 当前页 SEO 描述。
{$theme.name} 当前主题名称。
{$theme.assets} 当前主题静态资源目录。
{$query.page} URL 查询参数中的页码。
{$query.keyword} URL 查询参数中的关键词。
{$keyword} 搜索页关键词。

栏目页变量

栏目页、列表页、单页通常有 $category

变量 说明
{$category.id} 栏目 ID。
{$category.name} 栏目名称。
{$category.slug} 栏目访问目录。
{$category.type} 栏目类型。
{$category.description} 栏目描述。
{$category.list_page_size} 后台栏目设置的列表分页数量。
{$category.model.code} 绑定模型编码。
{$category.model.name} 绑定模型名称。

内容详情页变量

详情页通常有 $content,很多模板也会直接提供同名顶层字段:

变量 说明
{$content.id} 内容 ID。
{$content.title} 标题。
{$content.thumb} 缩略图。
{html $content.content} 正文 HTML。
{$content.description} 描述。
{$content.views} 浏览量。
{$content.views_short} 浏览量短格式。
{$content.published_at} 发布时间完整值。
{$content.published_at_date} 发布时间日期。
{$content.updated_at} 更新时间完整值。
{$content.updated_at_date} 更新时间日期。
{$content.category.name} 所属栏目。
{$content.model.code} 所属模型编码。
{$content.字段名} 自定义字段。

会员变量

登录后可使用 $member

变量 说明
{$member.id} 会员 ID。
{$member.username} 用户名。
{$member.nickname} 昵称。
{$member.avatar_url} 头像地址。
{$member.group_id} 会员组 ID。