玩织梦CMS的站长应该都知道DEDECMS的后台栏目管理中只有一个栏目内容,但是大多数都会觉得不够用,所有这就需要我们自己去二次开发栏目内容了。
第一步 为数据库新增一个栏目内容字段
和上一篇DEDECMS的文章一样,首先就需要我们添加一个字段到数据库。
下方语句的意思是,在dede_arctype的content字段后增加一个名为content1的text属性字段。
ALTER TABLE `dede_arctype` ADD `content1` TEXT NOT NULL AFTER `content` ;
或者直接在phpmyadmin中找到dede_arctype表,在其中插入一个字段即可。
第二步 为栏目管理中增加输入框
打开dede\templets\catalog_edit.htm 查找
function ShowItem1(){
将function ShowItem1- ShowItem3的js代码修改如下
function ShowItem1(){ ShowObj('head1'); ShowObj('needset'); HideObj('head2'); HideObj('adset'); HideObj('head3'); HideObj('ctset'); HideObj('head4'); HideObj('ctset1'); } function ShowItem2(){ ShowObj('head2'); ShowObj('adset'); HideObj('head1'); HideObj('needset'); HideObj('head3'); HideObj('ctset'); HideObj('head4'); HideObj('ctset1'); } function ShowItem3(){ ShowObj('head3'); ShowObj('ctset'); HideObj('head1'); HideObj('needset'); HideObj('head2'); HideObj('adset'); HideObj('head4'); HideObj('ctset1'); } function ShowItem4(){ ShowObj('head4'); ShowObj('ctset1'); HideObj('head3'); HideObj('ctset'); HideObj('head1'); HideObj('needset'); HideObj('head2'); HideObj('adset'); }
<table width="100%" border="0" cellspacing="0" id="head1" cellpadding="0"> <tr> <td colspan="2" bgcolor="#FFFFFF" align="left"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td width="84" height="24" align="center" background="images/itemnote1.gif"> 常规选项 </td> <td width="84" align="center" background="images/itemnote2.gif"><a href="#" onClick="ShowItem2()"><u>高级选项</u></a> </td> <td width="84" align="center" background="images/itemnote2.gif"><a href="#" onClick="ShowItem3()"><u>单页面内容</u></a> </td> <td width="84" align="center" background="images/itemnote2.gif"><a href="#" onClick="ShowItem4()"><u>底部内容说明</u></a> </td> </tr> </table> </td> </tr> </table> <table width="100%" border="0" cellspacing="0" id="head2" cellpadding="0" style="display:none"> <tr> <td colspan="2" bgcolor="#FFFFFF" style="text-align:left;"> <table height="24" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"><a href="#" onClick="ShowItem1()"><u>常规选项</u></a> </td> <td width="84" align="center" background="images/itemnote1.gif">高级选项 </td> <td width="84" align="center" background="images/itemnote2.gif"><a href="#" onClick="ShowItem3()"><u>单页面内容</u></a> </td> <td width="84" align="center" background="images/itemnote2.gif"><a href="#" onClick="ShowItem4()"><u>底部内容说明</u></a> </td> </tr> </table> </td> </tr> </table> <table width="100%" border="0" cellspacing="0" id="head3" cellpadding="0" style="display:none"> <tr> <td colspan="2" bgcolor="#FFFFFF" style="text-align:left;"> <table height="24" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"><a href="#" onClick="ShowItem1()"><u>常规选项</u></a> </td> <td width="84" align="center" background="images/itemnote2.gif"><a href="#" onClick="ShowItem2()"><u>高级选项</u> </td> <td width="84" align="center" background="images/itemnote1.gif">单页面内容 </td> <td width="84" align="center" background="images/itemnote2.gif"><a href="#" onClick="ShowItem4()"><u>底部内容说明</u></a> </td> </tr> </table> </td> </tr> </table> <table width="100%" border="0" cellspacing="0" id="head4" cellpadding="0" style="display:none"> <tr> <td colspan="2" bgcolor="#FFFFFF" style="text-align:left;"> <table height="24" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"><a href="#" onClick="ShowItem1()"><u>常规选项</u></a> </td> <td width="84" align="center" background="images/itemnote2.gif"><a href="#" onClick="ShowItem2()"><u>高级选项</u> </td> <td width="84" align="center" background="images/itemnote2.gif"><a href="#" onClick="ShowItem3()"><u>单页面内容</u></a> </td> <td width="84" align="center" background="images/itemnote2.gif">底部内容说明 </td> </tr> </table> </td> </tr> </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #cfcfcf;background:#ffffff;display:none;text-align:left;" id="ctset1"> <tr> <td height="28"> 说明:产品底部内容说明。</td> </tr> <tr> <td style="padding:10px;"> <?php GetEditor("content1",$myrow['content1'],"450","Default","print","false"); ?> </td> </tr> </table>
第三步 将新增字段同步数据库
然后打开dede/catalog_edit.php查找
`content`='$content',
在其后增加如下内容
`content1`='$content1',
至此就修改好了。
第四步 前台调用
在前台调用是使用如下标签即可
{dede:field.content1/}