Description: Used to get the city list
Usage:{% placeList 变量名称 with parentId="0" all="false" %}{% for item in 变量名称 %}...{% endfor %}{% endplaceList %}If the variable is defined as places{% placeList places with parentId="0" %}...{% endplaceList %}
The placeList supports the following parameters:
- Parent station
parentId
parentIdIndicates the parent station, which can retrieve the child stations under the specified parent station,parentId="parent"Represents the superior station as the superior station of the current station, used to obtain the brother stations of the current station.parentId="0"to obtain the top-level station. If not specified, it defaults to obtaining the sub-stations of the current station. - Get all stations
all
allYou can get the list of specified all stations, such asall=trueGet all stations (including all levels), default tofalseOnly get the direct child stations. - Show quantity
limit
limitYou can specify the number of items to display, for examplelimit="10"Then only 10 items will be displayed.limitSupportoffsetmode, namely,,delimiter mode, if you want to start from the second item and get 10 items, you can set it tolimit="2,10". - List type
listType
listTypeSupportlist(Normal list, default) andpageTwo modes (pagination list). When set topage, the pagination feature will be enabled, automatically obtaining the current page number from the URL parameters, and setting in the contextpaginationPage data. - Site ID
siteId
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.
If you want to get the child stations of the current sub-station, you do not need to specify.parentId. If you want to get the brother stations of the current sub-station, specify.parentId="parent", only valid when on the city sub-station detail page.
places is an array object, therefore it needs to usefora loop to output.
item is the variable within the for loop, the available fields are:
- Station ID
Id - Station Title
Title - Station SEO Title
SeoTitle - Station Keyword
Keywords - Station Description
Description - Station Link
Link - Station Thumbnail Large
Logo - Station Thumbnail
Thumb - Station Banner Group Image
Images - Parent Station ID
ParentId - Station Sorting Value
Sort - Creation time
CreatedTime - Update time
UpdatedTime - latitude
Latitude - longitude
Longitude - Time Zone
Timezone - Has Subordinate Station
HasChildren - Is Current Station
IsCurrent - Whether to expand the sub-level
Spacer
Code example
{% placeList places with parentId="0" %}
<ul>
{% for item in places %}
<li>
{# 如需判断当前是否是循环中的第一条,可以这么写: #}
{% if forloop.Counter == 1 %}这是第一条{% endif %}
{# 比如需要给第一条添加额外class="active",可以这么写: #}
<a class="{% if forloop.Counter == 1 %}active{% endif %}" href="{{item.Link}}">{{item.Title}}</a>
<a href="{{ item.Link }}">
<span>当前第{{ forloop.Counter }}个,剩余{{ forloop.Revcounter}}个</span>
<span>分站ID:{{item.Id}}</span>
<span>分站名称:{{item.Title}}</span>
<span>分站链接:{{item.Link}}</span>
<span>分站描述:{{item.Description}}</span>
<span>上级分站ID:{{item.ParentId}}</span>
<span>是否有下级分站:{{item.HasChildren}}</span>
</a>
<div>缩略图大图:<img style="width: 200px" src="{{item.Logo}}" alt="{{item.Title}}" /></div>
<div>缩略图:<img style="width: 200px" src="{{item.Thumb}}" alt="{{item.Title}}" /></div>
<div>经纬度:{{item.Latitude}}, {{item.Longitude}}</div>
</li>
{% endfor %}
</ul>
{% endplaceList %}
Nested call of multi-level station
{% placeList places with parentId="0" %}
{# 一级分站 #}
<ul>
{% for item in places %}
<li>
<a href="{{ item.Link }}">{{item.Title}}</a>
<div>
{% placeList subPlaces with parentId=item.Id %}
{# 二级分站 #}
<ul>
{% for inner1 in subPlaces %}
<li>
<a href="{{ inner1.Link }}">{{inner1.Title}}</a>
<div>
{% placeList subPlaces2 with parentId=inner1.Id %}
{# 三级分站 #}
<ul>
{% for inner2 in subPlaces2 %}
<li>
<a href="{{ inner2.Link }}">{{inner2.Title}}</a>
</li>
{% endfor %}
</ul>
{% endplaceList %}
</div>
</li>
{% endfor %}
</ul>
{% endplaceList %}
</div>
</li>
{% endfor %}
</ul>
{% endplaceList %}
Paging list usage
settinglistType="page"Enable paging mode, combinedpaginationthe tag to use:
{% placeList places with parentId="0" listType="page" limit="10" %}
<ul>
{% for item in places %}
<li>
<a href="{{ item.Link }}">{{item.Title}}</a>
</li>
{% empty %}
<li>该列表没有任何内容</li>
{% endfor %}
</ul>
{% endplaceList %}
{# 分页导航 #}
{% pagination with pagination %}
Common usage examples
- Get the child stations of the current station (used on the city station detail page):
{% placeList subPlaces with %}
<ul>
{% for item in subPlaces %}
<li><a href="{{ item.Link }}">{{item.Title}}</a></li>
{% endfor %}
</ul>
{% endplaceList %}
- Get the sibling stations of the current division (used on the city division detail page):
{% placeList siblingPlaces with parentId="parent" %}
<ul>
{% for item in siblingPlaces %}
<li><a href="{{ item.Link }}">{{item.Title}}</a></li>
{% endfor %}
</ul>
{% endplaceList %}
- Get the full list of all stations (unlimited levels):
{% placeList allPlaces with all="true" %}
<ul>
{% for item in allPlaces %}
<li>
<a href="{{ item.Link }}">{{item.Title}}</a>
</li>
{% endfor %}
</ul>
{% endplaceList %}