ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
自定义方法修改文件:include/extend.func.php ## 一、栏目增加自定义字段 ### 1.增加栏目缩略图、栏目英文名 ~~~ //字段名:arcpic,english ~~~ **a. 文件:catalog_add.htm** ~~~ <tr> <td class='bline' height="26" style="padding-left:10px;">栏目图片:</td> <td class='bline'> <input name="arcpic" type="text" value="<?php echo $arcpic?>" class="pubinputs" style="width:300px" /> <input type="button" name="set3" value="浏览... " class="coolbg np" style="width:60px" onClick="SelectImage('form1.arcpic','small');" /> </td> </tr> <tr> <td class='bline' height="26" style="padding-left:10px;"><font>英文名:</font></td> <td class='bline'><input name="english" type="text" id="english" size="30" class="iptxt" /></td> </tr> ~~~ **b. 文件:catalog_edit.htm** ~~~ <tr> <td height="26">栏目图片:</td> <td> <input name="arcpic" type="text" value="<?php echo $myrow['arcpic']?>" class="pubinputs" style="width:300px" /> <input type="button" name="set3" value="浏览... "class="coolbg np" style="width:60px" onClick="SelectImage('form1.arcpic','small');" /> </td> </tr> <tr> <td class='bline' height="26"><font color='red'>英文名:</font></td> <td class='bline'><input name="english" type="text" id="english" size="30" value="<?php echo $myrow['english']?>" class="iptxt" /></td> </tr> ~~~ **c.以上2个文件需要增加js文件** ~~~ <script language="javascript" src="../include/dedeajax2.js"></script> <script language='javascript' src='js/main.js'></script> ~~~ **e. mysql运行字段添加到数据库** ~~~ ALTER TABLE `dede_arctype` ADD `arcpic` VARCHAR(128); ALTER TABLE `dede_arctype` ADD `english` VARCHAR(64); ~~~ ## 二、自定义方法 ### 1、获取顶级栏目名称 ~~~ function GetTopTypename($id) { global $dsql; $row = $dsql->GetOne("SELECT typename,topid FROM `#@__arctype` WHERE id= $id"); if ($row['topid'] == '0') { return $row['typename']; } else { $row1 = $dsql->GetOne("SELECT typename FROM `#@__arctype` WHERE id= $row[topid]"); return $row1['typename']; } } ~~~ 调用方式 ~~~ {dede:field name='typeid' function="GetTopTypename(@me)" /} ~~~ ### 2、获取顶级栏目英文名称 ~~~ function GetTopEnname($id) { global $dsql; $row = $dsql->GetOne("SELECT english,topid FROM `#@__arctype` WHERE id= $id"); if ($row['topid'] == '0') { return $row['english']; } else { $row1 = $dsql->GetOne("SELECT english FROM `#@__arctype` WHERE id= $row[topid]"); return $row1['english']; } } ~~~ 调用方式 ~~~ {dede:field name='typeid' function="GetTopEnname(@me)" /} ~~~