Category Details Tag

Description: Used to get the details of the document's category

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

The parameters supported by categoryDetail are:

  • Category IDid idNot required, it will get the current category by default. To specify a category, you can set the id.
  • Category URL aliastoken tokenIt is not necessary; the current category will be obtained by default. To specify a category, you can set the id or token to achieve this.
  • Site IDsiteId siteIdGenerally, it is not necessary to fill in. If you have created multiple sites using the multi-site management on the backend and want to call data from other sites, you can do so by specifyingsiteIdTo implement the call to data from a 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 Large ImageLogo
  • Category ThumbnailThumb
  • Category Banner ImagesImages
  • Number of documents in the categoryArchiveCount
  • Other field parameters for category settings in document model

Category 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>

Category 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 LinkLink

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>

Category 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>

Category ContentContent

Tag Usage:{% categoryDetail with name="Content" %}

The Content field will automatically convert content 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 perform the conversion, and you need to addrenderParameters. Acceptsfalse|trueTwo values.render=falseNo Markdown to html conversion is performed,render=trueConversion is performed.

{# 默认用法,自动获取当前页面分类 #}
<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

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 in the categoryArchiveCount

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>

Other field parameters for category settings in document model

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

{% categoryDetail with name="author" %}

The use of custom field parameters, for example, you have customized a field for a group image, ascatimagesAnd 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 use it like this:

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

It defaults to cycling through all custom fields. If you don't want certain custom fields to appear, for example, not to showauthor/priceUse the field on the page 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 Large ImageLogo

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>

Category ThumbnailThumb

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>

Category Banner ImagesImages

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 code will demonstrate 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>