๐ Current & Specific Categories
Last updated๏ผ2026-11-25
๐ Current Category / Specific Category
Category data and category control parameters. Admin path: Admin โ Content Management โ Category Management
๐ Current Category Fields
The following fields are directly available on category pages (e.g. /products/glass/).
- {{.CategoryName}} Current category name (the category page hero headline reads the category name straight from the database) โ text
- {{.CategorySubTitle}} Current category subtitle (one line below the category name, filled in via admin “Category Management โ Subtitle”; channel pages products/news/cases/jobs also pass it through from the corresponding category link) โ text
- {{.CategoryDescription}} Category description 1 โ text
- {{.CategoryDescription2}} Category description 2 โ text
- {{.CategoryDescription3}} Category description 3 โ text
- {{.CategoryRedirectURL}} Redirect link (visitors are redirected immediately when opening this category) โ URL
- {{.CategoryPermissionDeniedMessage}} Permission-denied message โ text
- {{.CategoryThumbnail}} Category thumbnail URL โ URL
- {{.CategoryImage}} Category large image / banner URL โ URL
- {{.CategoryLink}} Current category link โ URL
- {{.SEOTitle}} Current category SEO title โ SEO
- {{.SEOKeywords}} Current category SEO keywords โ SEO
- {{.SEODescription}} Current category SEO description โ SEO
๐ Category Control Parameters NEW
The following variables are available on all pages (globally injected), so any template can access category info. - {{.CurrentCategory.Name}} Current category object (with ID/Name/Link/ParentID/Type/SubTitle/Description/Description2/Description3/RedirectURL/PermissionDeniedMessage/Thumbnail/Image/ViewPermission/PermissionType) โ object - {{.CurrentCategory.SubTitle}} Current category subtitle (object syntax, equivalent to the top-level {{.CategorySubTitle}}) โ text - {{.CategoryMeta.Image}} Large image of the category on channel pages (products/news/cases/jobs), read via the {{.CategoryMeta}} object โ URL - {{.ParentCategory.Name}} Parent category (direct parent object) โ object - {{range .ChildCategories}} Child category list (direct children of the current category) โ array - {{range .TopCategories}} Top-level category list (all first-level categories, for navigation / category trees) โ array
๐งญ Category Control Parameter Quick Reference
| Scenario | Go Template Syntax | Description |
|---|---|---|
| Current category | {{.CurrentCategory.Name}} |
Show the current category name on the category page |
| Parent category | {{if .ParentCategory}}{{.ParentCategory.Name}}{{end}} |
The parent of the current category (for breadcrumbs) |
| Child categories | {{range .ChildCategories}}... |
Iterate the children of the current category |
| Top-level categories | {{range .TopCategories}} |
Iterate all first-level categories (navigation / sidebar category tree) |
| Specific category | {{range list "type=news&scode=category-link"}} |
Fetch content of a specific category (including its children) |
Each category object contains: ID (category ID), Name (category name), Link (category link), Type (content model code: news article / product product / case case / job job / page single page / or a custom model code such as certificate). A category’s “content model” is selected from a dropdown when adding/editing a category in the admin; the dropdown items are the models enabled under the admin’s “Content Models”.
๐ป Usage Example
<!-- Category page hero headline (reads the category name from the database) -->
<h1>{{.CategoryName}}</h1>
<!-- Category subtitle (filled in via admin "Category Management โ Subtitle"; falls back to default copy when empty) -->
{{if .CategorySubTitle}}<p class="page-hero-desc">{{.CategorySubTitle}}</p>{{end}}
<!-- Sidebar category tree: top-level categories + children -->
{{range .TopCategories}}
<a href="{{.Link}}">{{.Name}}</a>
{{end}}
<!-- Breadcrumb: parent / current -->
{{if .ParentCategory}}<a href="{{.ParentCategory.Link}}">{{.ParentCategory.Name}}</a> / {{end}}{{.CategoryName}}
<!-- Category page content list: pick the matching variable per the category's "content model" -->
<!-- Article category (default) โ .Posts / .News -->
{{range .Posts}}<a href="{{.URL}}">{{.Title}}</a>{{end}}
<!-- Product category โ .Products (also compatible with .Posts) -->
{{range .Products}}<a href="{{.URL}}">{{.Title}}</a>{{end}}
<!-- Case category โ .Cases -->
{{range .Cases}}<a href="{{.URL}}">{{.Title}}</a>{{end}}
<!-- Job category โ .Jobs (with .Location/.Salary/.EmploymentType) -->
{{range .Jobs}}<a href="{{.URL}}">{{.Title}}</a>{{end}}
<!-- Custom content model category โ .CustomItems / .List (generic aliases .Posts/.News also work) -->
{{range .CustomItems}}<a href="{{.URL}}">{{.Title}}</a>{{end}}
๐ฏ Specific Category (free-tag scode)
Via the scode parameter of the list function, fetch content from a specific category (including its children).
<!-- Latest 6 items from the news category -->
{{range list "type=news&num=6&order=date"}}
<a href="{{.URL}}">{{.Title}}</a>
{{end}}
<!-- Featured products from the product category (including children) -->
{{range list "type=product&num=6&order=istop&scode=display-glass"}}
<a href="{{.URL}}">{{.Title}}</a>
{{end}}
๐งฉ Custom Content Model Categories NEW
In the admin “Content Models” you can create custom models (tables model_, e.g. certificates ascertificate`), and when “adding a category” select this custom model as the category’s “content model”. Front-end rendering for such categories goes through the generic list branch:
| Injected Variable | Description |
|---|---|
{{.CustomItems}} / {{.List}} |
Custom model content array (primary variable) |
{{.Posts}} / {{.News}} |
Compatibility aliases pointing to the same array (handy for reusing article list templates) |
{{.ModelCode}} |
Current custom model code (e.g. certificate) |
{{.URL}} (per item) |
Detail link, auto-generated by the system as /m//; always use .URL rather than hand-writing it |
Available fields per array item: .Title / .Summary / .Image / .Thumbnail / .CreatedAt / .IsRecommend / .URL, plus the extended fields defined for that model in the admin (field names are the database column names, e.g. {{.cert_no}}).
<!-- Custom model category list (e.g. /category/cert) -->
{{range .CustomItems}}
<div class="card">
<a href="{{.URL}}">{{.Title}}</a>
<p>{{.Summary}}</p>
{{if .cert_no}}<span>Certificate No.: {{.cert_no}}</span>{{end}}
</div>
{{end}}
For detail pages, see the “Content Detail” chapter’s Custom Content Model Detail (model_detail.html). Custom model content is stored in a separate table and does not interfere with articles/products; it is entered via the admin “Content Models โ Model Content”.
CloudSite SaaS