Category Details Label

Description: Used to get the document category details

Usage:{% categoryDetail 变量名称 with name="字段名称" id="1" %}The variable name is not required. After setting the variable name, it can be called later by the variable name, and if the variable name is not set, it is output directly.

Parameters supported by categoryDetail:

  • Category IDid idIt is not required, the current category will be obtained by default. If you need to specify a category, you can do so by setting the id.
  • Category URL Aliastoken tokenIt is not required, the current category will be retrieved by default. If you need to specify a category, you can do so by setting id or token.
  • Site IDsiteId siteIdGenerally, it is not necessary to fill in, if you use the multi-site management on the backend to create multiple sites and want to call data from other sites, you can specifysiteIdTo call the data of the specified site.

The fields available for the name parameter are:

  • Category IDId
  • category titleTitle
  • Category linkLink
  • Category descriptionDescription
  • Category contentContent
  • Parent Category IDParentId
  • Category Thumbnail LargeLogo
  • Category ThumbnailThumb
  • Category Banner Group ImageImages
  • Number of documents in the categoryArchiveCount
  • Parameters for the category settings of the document model

Category IDId

Label usage:{% categoryDetail with name="Id" %}

{# 默认用法,自动获取当前页面分类 #}
<div>分类ID:{% categoryDetail with name="Id" %}</div>
{# 获取指定分类id的分类字段 #}
<div>分类ID:{% categoryDetail with name="Id" id="1" %}</div>
{# 自定义字段名称 #}
<div>分类ID:{% categoryDetail categoryId with name="Id" %}{{categoryId}}</div>
<div>分类ID:{% categoryDetail categoryId with name="Id" id="1" %}{{categoryId}}</div>

category titleTitle

Label usage:{% categoryDetail with name="Title" %}

{# 默认用法,自动获取当前页面分类 #}
<div>分类标题:{% categoryDetail with name="Title" %}</div>
{# 获取指定分类id的分类字段 #}
<div>分类标题:{% categoryDetail with name="Title" id="1" %}</div>
{# 自定义字段名称 #}
<div>分类标题:{% categoryDetail categoryTitle with name="Title" %}{{categoryTitle}}</div>
<div>分类标题:{% categoryDetail categoryTitle with name="Title" id="1" %}{{categoryTitle}}</div>

Category linkLink

Label usage:{% categoryDetail with name="Link" %}

{# 默认用法,自动获取当前页面分类 #}
<div>分类链接:{% categoryDetail with name="Link" %}</div>
{# 获取指定分类id的分类字段 #}
<div>分类链接:{% categoryDetail with name="Link" id="1" %}</div>
{# 自定义字段名称 #}
<div>分类链接:{% categoryDetail categoryLink with name="Link" %}{{categoryLink}}</div>
<div>分类链接:{% categoryDetail categoryLink with name="Link" id="1" %}{{categoryLink}}</div>

Category descriptionDescription

Label usage:{% categoryDetail with name="Description" %}

{# 默认用法,自动获取当前页面分类 #}
<div>分类描述:{% categoryDetail with name="Description" %}</div>
{# 获取指定分类id的分类字段 #}
<div>分类描述:{% categoryDetail with name="Description" id="1" %}</div>
{# 自定义字段名称 #}
<div>分类描述:{% categoryDetail categoryDescription with name="Description" %}{{categoryDescription}}</div>
<div>分类描述:{% categoryDetail categoryDescription with name="Description" id="1" %}{{categoryDescription}}</div>

Category contentContent

Label usage:{% categoryDetail with name="Content" %}

Content field will automatically convert Markdown to html when the Markdown editor is enabled. After the Markdown editor is disabled, the Content content will not automatically convert to html. However, you can manually specify whether to convert, and it needs to be addedrenderParameters. Acceptfalse|trueTwo values.render=falseDo not perform Markdown to html conversion,render=truePerform conversion.

{# 默认用法,自动获取当前页面分类 #}
<div>分类内容:{% categoryDetail with name="Content" %}</div>
{# 获取指定分类id的分类字段 #}
<div>分类内容:{% categoryDetail with name="Content" id="1" %}</div>
{# 自定义字段名称 #}
<div>分类内容:{% categoryDetail categoryContent with name="Content" %}{{categoryContent|safe}}</div>
<div>分类内容:{% categoryDetail categoryContent with name="Content" id="1" %}{{categoryContent|safe}}</div>

Parent Category IDParentId

Label usage:{% categoryDetail with name="ParentId" %}

{# 默认用法,自动获取当前页面分类 #}
<div>上级分类ID:{% categoryDetail with name="ParentId" %}</div>
{# 获取指定分类id的分类字段 #}
<div>上级分类ID:{% categoryDetail with name="ParentId" id="1" %}</div>
{# 自定义字段名称 #}
<div>上级分类ID:{% categoryDetail categoryParentId with name="ParentId" %}{{categoryParentId}}</div>
<div>上级分类ID:{% categoryDetail categoryParentId with name="ParentId" id="1" %}{{categoryParentId}}</div>

Number of documents in the categoryArchiveCount

Label usage:{% categoryDetail with name="ArchiveCount" %}

{# 默认用法,自动获取当前页面分类 #}
<div>分类文档数量:{% categoryDetail with name="ArchiveCount" %}</div>
{# 获取指定分类id的分类字段 #}
<div>分类文档数量:{% categoryDetail with name="ArchiveCount" id="1" %}</div>
{# 自定义字段名称 #}
<div>分类文档数量:{% categoryDetail archiveCount with name="ArchiveCount" %}{{archiveCount}}</div>
<div>分类文档数量:{% categoryDetail archiveCount with name="ArchiveCount" id="1" %}{{archiveCount}}</div>

Parameters for the category settings of the document model

If you want to display the content of a custom field, such as the custom field you defined asauthorthen you can call it like this in the template:

{% categoryDetail with name="author" %}

The use of custom field parameters, for example, you have customized a field for a group chart, it is forcatimagesAnd if you want to display them on the front end, you can write it like this:

{% categoryDetail catimages with name="catimages" %}
<ul class="category-images">
  {% for img in catimages %}
  <li><img src="{{img}}" /></li>
  {% endfor %}
</ul>

If you want to loop through all custom fields, you can do it like this:

{% categoryDetail extras with name="Extra" %}
{% for field in extras %}
  <div>{{field.Name}}:{{field.Value}}</div>
{% endfor %}

It will loop through all custom fields by default, if you don't want some custom field to appear, for example, you don't wantauthor/priceto display the field on the page, you can use it like this:

{% categoryDetail extras with name="Extra" %}
{% for field in extras %}
{% if field.Name != 'author' and field.Name != 'price' %}
  <div>{{field.Name}}:{{field.Value}}</div>
{% endif %}
{% endfor %}

Category Thumbnail LargeLogo

Label usage:{% categoryDetail with name="Logo" %}

{# 默认用法,自动获取当前页面分类 #}
<div>缩略图大图:<img style="width: 200px" src="{% categoryDetail with name="Logo" %}" alt="{% categoryDetail with name="Title" %}" /></div>
{# 获取指定分类id的分类字段 #}
<div>缩略图大图:<img style="width: 200px" src="{% categoryDetail with name="Logo" id="1" %}" alt="{% categoryDetail with name="Title" id="1" %}" /></div>
{# 自定义字段名称 #}
<div>缩略图大图:{% categoryDetail categoryLogo with name="Logo" %}<img style="width: 200px" src="{{categoryLogo}}" alt="{% categoryDetail with name="Title" %}" /></div>
<div>缩略图大图:{% categoryDetail categoryLogo with name="Logo" id="1" %}<img style="width: 200px" src="{{categoryLogo}}" alt="{% categoryDetail with name="Title" %}" /></div>

Category ThumbnailThumb

Label usage:{% categoryDetail with name="Thumb" %}

{# 默认用法,自动获取当前页面分类 #}
<div>缩略图大图:<img style="width: 200px" src="{% categoryDetail with name="Thumb" %}" alt="{% categoryDetail with name="Title" %}" /></div>
{# 获取指定分类id的分类字段 #}
<div>缩略图大图:<img style="width: 200px" src="{% categoryDetail with name="Thumb" id="1" %}" alt="{% categoryDetail with name="Title" id="1" %}" /></div>
{# 自定义字段名称 #}
<div>缩略图大图:{% categoryDetail categoryThumb with name="Thumb" %}<img style="width: 200px" src="{{categoryThumb}}" alt="{% categoryDetail with name="Title" %}" /></div>
<div>缩略图大图:{% categoryDetail categoryThumb with name="Thumb" id="1" %}<img style="width: 200px" src="{{categoryThumb}}" alt="{% categoryDetail with name="Title" %}" /></div>

Category Banner Group ImageImages

Label usage:{% categoryDetail categoryImages with name="Images" %}{% for item in categoryImages %}<img src="{{item}}" alt="{% categoryDetail with name="Title" %}" />{% endfor %}

{% categoryDetail categoryImages with name="Images" %}
<ul>
{% for item in categoryImages %}
  <li>
    <img src="{{item}}" alt="{% categoryDetail with name="Title" %}" />
  </li>
{% endfor %}
</ul>

The code will display multiple slides. If you only need the first image and want to check if the image exists, you can use the following method:

{% categoryDetail bannerImages with name="Images" %}
{% if bannerImages %}
{% set pageBanner = bannerImages[0] %}
{% endif %}
<img src="{{pageBanner}}" />

If you want to use it as a background image, you can do it like this:

{% categoryDetail bannerImages with name="Images" %}
{% if bannerImages %}
{% set pageBanner = bannerImages[0] %}
{% endif %}
<div class="page-banner" style="background: url({{pageBanner}}) no-repeat;">
</div>