Description: Used to obtain the classification details of the document
How to use:{% categoryDetail 变量名称 with name="字段名称" id="1" %}
The variable name is not necessary. After setting the variable name, you can call it through the variable name in the future. Without setting the variable name, the result will be output directly.
The supported parameters of categoryDetail are:
- Classification ID
id
id
It is not necessary, the current classification will be obtained by default. If you need to specify a classification, you can achieve the purpose by setting the id. - Classified URL alias
token
token
It is not necessary, the current classification will be obtained by default. If you need to specify a classification, you can achieve the purpose by setting the id or token. - Site ID
siteId
siteId
Generally, there is no need to fill in it. If you use the background multi-site management to create multiple sites and want to call data from other sites, you can specify itsiteId
To implement the data calling the specified site.
The fields available for the name parameter are:
- Classification ID
Id
- Classification title
Title
- Category Links
Link
- Classification Description
Description
- Classified content
Content
- Superior Class ID
ParentId
- Classified thumbnails
Logo
- Classification thumbnails
Thumb
- Classification Banner Photos
Images
- Number of documents classified
ArchiveCount
- Classification other field parameters for document model settings
Classification IDId
Tag 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>
Classification titleTitle
Tag 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 LinksLink
Tag 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>
Classification DescriptionDescription
Tag 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>
Classified contentContent
Tag usage:{% categoryDetail with name="Content" %}
{# 默认用法,自动获取当前页面分类 #}
<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>
After the Content field is enabled, the content will automatically convert the content to html. After closing the Markdown editor, the Content content will not automatically convert the content to html. But you can manually specify whether to convert, you need to addrender
parameter. acceptfalse|true
Two values.render=false
No Markdown to html operation is performed.render=true
Make a conversion.
Superior Class IDParentId
Tag 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 classifiedArchiveCount
Tag 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>
Classification other field parameters for document model settings
If you want to display the contents of a custom field, if your custom field isauthor
, then you can call it like this in the template:
{% categoryDetail with name="author" %}
If you want to loop out all custom fields, you can use this:
{% categoryDetail extras with name="Extra" %}
{% for field in extras %}
<div>{{field.Name}}:{{field.Value}}</div>
{% endfor %}
Classified thumbnailsLogo
Tag 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>
Classification thumbnailsThumb
Tag 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>
ClassificationBannerPhotosImages
Tag 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 above code will show multiple slides.
If you only need the first image and determine whether the image exists, you can use the following methods:
{% 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 this:
{% categoryDetail bannerImages with name="Images" %}
{% if bannerImages %}
{% set pageBanner = bannerImages[0] %}
{% endif %}
<div class="page-banner" style="background: url({{pageBanner}}) no-repeat;">
</div>