Home > CMS Tutorial > DEDECMS > How does DedeCMS circularly call multi-level columns and content lists?

How does DedeCMS circularly call multi-level columns and content lists?

藏色散人
Release: 2020-01-03 09:07:54
Original
2652 people have browsed it

How does DedeCMS circularly call multi-level columns and content lists?

How does DedeCMS circularly call multi-level columns and content lists?

DedeCMS loops to call multi-level columns and content lists

Recommended learning: Dreamweavercms

Dedecms is quite good, of course. In addition to the technical reply speed of the forum! ! Today I will share a relatively practical small code for cyclically calling sub-columns and their content lists. In fact, you can also see it by looking at the tag manual, but after all, there are still lazy people!

According to the tag manual, in the DedeCMS system, the channelartlist tag can be used to cycle sub-columns and their column data. It is said that it is also the only one in the DedeCMS system that supports tag nesting. The basic usage of calling tags is as follows, which can be modified as needed:

<div> 
{dede:channelartlist}  
<dl> 
<dt><strong><a href="{dede:field name=&#39;typeurl&#39;/}">{dede:field name=&#39;typename&#39;/}</a></strong>
<span><a href="{dede:field name=&#39;typeurl&#39;/}">更多...</a></span></dt> 
<dd> 
<ul> 
{dede:arclist titlelen=&#39;60&#39; row=&#39;8&#39;}  
<li><span>[field:pubdate function="MyDate(&#39;m-d&#39;,@me)&#39;/]</span><a href="[field:arcurl /]">
[field:title /]</a></li> 
{/dede:arclist}  
</ul> 
</dd> 
</dl> 
{/dede:channelartlist}  
</div>
Copy after login

The above code can realize the calling of sub-columns and sub-column content lists on the home page! Let’s talk about the use of the channelartlist tag on list pages and content pages.

1. Parameter introduction

The channelartlist tag temporarily supports three parameters, which are:

typeid='0' to limit the upper-level column ID; you can also use top, which supports " ," indicates multiple columns

row='20' The number of columns to cycle, the default is 20;

cacheid = '' tag cache ID, usually empty

but If you just copy and paste the above code unchanged to the ultimate column page or content page, no call results will appear, because in the tag channelartlist, when the typeid is empty, it means the current column, but the ultimate column list and The content page has no subordinate columns, so an error will occur!

2. Calling example

On the ultimate list page or content page, the correct calling method should be the following:

{dede:channelartlist typeid='top'}

Here is typed='top'. The top value can be replaced by the upper-level column ID you want, but it must not be empty. Everyone must pay attention to this!

3. Column highlighting and special effect calling

Under this label, you can directly use {dede:field name='typename'/} and {dede:field name='typeurl' respectively. /} to represent the column name and column link. Of course, there are some other special variables, which are also introduced here, such as:

{dede:field name=&#39;id&#39;/}与{dede:field name=&#39;typeid&#39;/} 均表示循环中的栏目ID;
{dede:global name=&#39;itemindex&#39;} 表示循环递增变量,从1开始;
{dede:global name=&#39;itemparity&#39;} 表示循环魔法变量,单数为1,双数为2;
Copy after login

The above can be applied directly in channelartlist. Special attention should be paid to the first 2 and 3. With these two variables, you can easily create various very personalized effects, such as changing the color of columns every other row.

Regarding the highlighting of this column, channelartlist.lib.php does not come with it, but through the following DIY, the current column can be highlighted. Method (taking dedecms 5.6 as an example):

Open the channelartlist.lib.php file and find the following code:

$pv->Fields[&#39;typeurl&#39;] = GetOneTypeUrlA($typeids[$i]);
Copy after login

Add the following code to the next line:

if($typeids[$i][&#39;id&#39;] == $refObj->TypeLink->TypeInfos[&#39;id&#39;]){  
$pv->Fields[&#39;currentstyle&#39;] = &#39; id="pic_focus"&#39;;  
}  
else{  
$pv->Fields[&#39;currentstyle&#39;] = &#39;&#39;;  
}
Copy after login

Then , you can use {dede:field name='currentstyle'/} to call it in the template.

The above is the detailed content of How does DedeCMS circularly call multi-level columns and content lists?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template