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='typeurl'/}">{dede:field name='typename'/}</a></strong> <span><a href="{dede:field name='typeurl'/}">更多...</a></span></dt> <dd> <ul> {dede:arclist titlelen='60' row='8'} <li><span>[field:pubdate function="MyDate('m-d',@me)'/]</span><a href="[field:arcurl /]"> [field:title /]</a></li> {/dede:arclist} </ul> </dd> </dl> {/dede:channelartlist} </div>
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='id'/}与{dede:field name='typeid'/} 均表示循环中的栏目ID; {dede:global name='itemindex'} 表示循环递增变量,从1开始; {dede:global name='itemparity'} 表示循环魔法变量,单数为1,双数为2;
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['typeurl'] = GetOneTypeUrlA($typeids[$i]);
Add the following code to the next line:
if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id']){ $pv->Fields['currentstyle'] = ' id="pic_focus"'; } else{ $pv->Fields['currentstyle'] = ''; }
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!