๐Ÿ“‹ Content Lists

Last updated๏ผš2026-11-25

๐Ÿ“‹ Content List

The unified approach for the three content list types: articles / products / cases. Admin path: Admin โ†’ Content Management

โš ๏ธ Field Location Notes

  • List pages: iterate {{.News}} / {{.Products}} / {{.Cases}} / {{.Jobs}} / {{.CustomItems}} (arrays) directly; each item’s fields have no prefix (e.g. .Title). Job categories use {{.Jobs}}, and custom content model categories use {{.CustomItems}} (compatibility alias {{.Posts}}).
  • Detail pages: single objects need a prefix (.News.Title / .Product.Title / .Case.Title)
  • Price Price is only available on detail pages; Client Client is only available on case detail pages

๐Ÿ“‹ Available Fields

  • {{.Title}} Title โ€” text
  • {{.Description}} Description (product/case lists) โ€” text
  • {{.Summary}} Summary (news lists) โ€” text
  • {{.Image}} Main image URL โ€” image
  • {{.Thumbnail}} Thumbnail URL โ€” image
  • {{.CreatedAt}} Publish time (news lists only) โ€” text
  • {{.IsRecommend}} Whether featured (1 = featured) โ€” number
  • {{.URL}} Content detail link (injected automatically by the system, includes the site prefix, usable directly in ). Its form is determined by the admin “Configuration Parameters โ†’ URL Rules” (may carry a .html suffix, use aliases for naming); always use it as-is in templates โ€” do not hand-write /news/{{.ID}} โ€” URL

๐Ÿ’ป Usage Example

<!-- Product list page (products.html) -->
{{range .Products}}
<div class="product-card">
  <img src="{{.Image}}" alt="{{.Title}}" loading="lazy">
  <h3>{{.Title}}</h3>
  <p>{{.Description}}</p>
</div>
{{end}}
<!-- News list page (news.html) -->
{{range .News}}
<article>
  <h2><a href="{{.URL}}">{{.Title}}</a></h2>
  <img src="{{.Image}}" alt="{{.Title}}" loading="lazy">
  <p>{{.Summary}}</p>
  <span>{{formatDate .CreatedAt "Y-m-d"}}</span>
</article>
{{end}}
<!-- With featured badge + image fallback (products) -->
<div class="product-grid">
{{range .Products}}
<a href="{{.URL}}" class="product-card">
  <div class="product-img">
    {{if .Thumbnail}}<img src="{{.Thumbnail}}" alt="{{.Title}}" loading="lazy">
    {{else if .Image}}<img src="{{.Image}}" alt="{{.Title}}" loading="lazy">
    {{else}}<img src="/static/images/product1.png" alt="{{.Title}}">{{end}}
  </div>
  {{if .IsRecommend}}<span class="badge">Featured</span>{{end}}
  <h3>{{.Title}}</h3>
  <p>{{.Description}}</p>
</a>
{{end}}
</div>

โš™๏ธ Free Tag Function (list)

Anywhere in a template, fetch data from the database dynamically via the function (supports count, ordering, and category filtering).

<!-- Generic syntax: type + num + order + scode + site -->
{{range list "type=news&num=6&order=date&scode=xxx"}}
<a href="{{.URL}}">{{.Title}}</a>
<span>{{.CreatedAt}}</span>
{{end}}
๐Ÿ“‹ Parameter Description
Parameter Description Default
type Content type: news / product / case / job / page or a custom model code (e.g. certificate) -
num Count 10
order Ordering: date (time) / id (ID) / istop (featured first, is_recommend DESC) id
scode Category filter (category link or id) -
site Site ID (multilingual) 1

Returned fields: each record contains ID, Title, Summary/Description, Image, Thumbnail, CreatedAt, IsRecommend (whether featured), URL (detail page link, injected automatically by the system). Use {{if .IsRecommend}} to test for featured items and {{.URL}} to link to details.

โš ๏ธ ๆณจๆ„

When using list with order or scode to fetch products / cases, results only contain .Summary, not .Description (.Description is present only when these two parameters are omitted). For compatibility with both forms, product / case lists should consistently use .Summary.

<!-- Fetch featured content with list (featured items first) -->
{{range list "type=product&num=6&order=istop"}}
{{if .IsRecommend}}<span class="badge">Featured</span>{{end}}
<a href="{{.URL}}">{{.Title}}</a>
{{end}}
๐Ÿงฉ Jobs / Custom Models Also Go Through list

Jobs use type=job; custom models created in the admin use their model code (see the admin “Content Models”). Beyond the common fields, custom models also return the extended fields defined for them in the admin (field names are column names).

”`html {{range list “type=job&num=8&order=date”}} {{.Title}} ยท {{.Location}} ยท {{.Salary}} {{end}}

{{range list “type=certificate&num=6”}} {{.Title}} {{end}} “` โ† Current Category Pagination Bar โ†’

This site uses cookies for essential functionality and to improve your experience. See our Privacy Policy.