Home  >  Article  >  CMS Tutorial  >  How to call the linkage category on the homepage of dedecms 5.6

How to call the linkage category on the homepage of dedecms 5.6

藏色散人
藏色散人Original
2019-12-14 10:29:272037browse

How to call the linkage category on the homepage of dedecms 5.6

dedecms 5.6 How to call the linkage category on the homepage?

Implementation method:

Step one: Add the following function to channelunit.func.php

//参数说明:第1个参数是从信息表里读取出来的类别ID,第2个参数是联动菜单类别 //这样这个函数就不限于只调用分类信息的信息类别了,还可以用于其它地方 function GetInfoType($tid,$bigt) { global $dsql; $typename = ''; $query = "Select ename From `dede_sys_enum` where evalue=$tid and egroup='$bigt'"; $dsql->Execute('ename',$query); while($row = $dsql->GetArray('ename')) { $typename .= ($typename=='' ? $row['ename'] : ','.$row['ename']); } return $typename; } //------------------ Add By CxChina.Com ----- End ------------------------- 复制代码 (V5.3)加到\include\common.func.php文件的 class="quote"> 
//自定义函数接口

above.

Recommended learning: 梦Weavercms

Step 2: Please use class="quote">

{dede:arclist row=14 titlelen=32 noflag='h' addfields='nativeplace' channelid='1'} 
<li>[[field:nativeplace function=GetInfoType(@me,&#39;nativeplace&#39;)/]] <a href="[field:arcurl/]">[field:title/]</a></li> 
{/dede:arclist}

on the front page to debug.

Code explanation:

1.addfields='nativeplace' channelid='1'This is the additional table field called;

①. Why Want to call additional table fields?

Because the value of the linkage menu is stored in the additional table, think carefully about whether you have added a custom linkage menu field yourself!

②. What does the channelid parameter mean?

Tell the parsing function which table your additional table is in! What you tell here is the ID of the additional table, so you believe that the program will automatically find the additional table corresponding to the ID in the content model.

2.[field:nativeplace /] This is the enumeration value of the document linkage menu called. The additional table stores only the values ​​of the corresponding enumeration values ​​in the linkage category.

3. function=GetInfoType This is our custom function call above! This cannot be changed.

4.(@me,'nativeplace') There are two variables here, the first one is @me which means the current value, which is fixed. To put it bluntly, it tells us the customization above The value of the enumeration value to be queried by the function. The second one is the cache group name of the linkage menu, which is generally consistent with the red nativeplace field name in the previous [field:nativeplace/].

The above is the detailed content of How to call the linkage category on the homepage of dedecms 5.6. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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