就以添加一个栏目别名为例子吧!
1.首先进入phpmyadmin 用来建立数据库字段。进入这个数据库进行如下图操作:
(如果后台直接运行
ALTER TABLE dede_arctype ADD typename2 VARCHAR(255);
这个SQL语句,也是可以直接创建这个字段的,请跳过1-3步骤直接从第4个步骤开始)
2.
点击进入以后进行下图的操作,红色框内要注意一下。(在页面的下面):
3.会出现一个这个图形界面,红色框内是你要填写的:保存以后数据库字段就算建立好了!
4.下面要做后台的表单部分
打开:\dede\templets\模板下的catalog_add.htm这个文件,最好用DW之类的网页编辑器去打开编辑。
找到如下代码:
<tr> <td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目名称:</font></td> <td class='bline'><input name="typename" type="text" id="typename" size="30" class="iptxt" /></td> </tr>
在下面添加:
<tr> <td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目别名:</font></td> <td class='bline'><input name="typename2" type="text" id="typename2" size="30" class="iptxt" /></td> </tr>
打开:\dede\templets\模板下的catalog_edit.htm这个文件,最好用DW之类的网页编辑器去打开编辑。
找到以下代码:
<tr> <td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目名称:</font></td> <td class='bline'><input name="typename" type="text" id="typename" size="30" value="<?php echo $myrow['typename']?>" class="iptxt" /></td> </tr>
在下面加:
<tr> <td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目别名:</font></td> <td class='bline'><input name="typename2" type="text" id="typename" size="30" value="<?php echo $myrow['typename2']?>" class="iptxt" /></td> </tr>
5.PHP部分的修改:
打开:\dede\catalog_add.php文件,最好用DW之类的网页编辑器去打开编辑.
找到:
$queryTemplate = "INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir,isdefault,defaultname,issend,channeltype, tempindex,templist,temparticle,modname,namerule,namerule2,ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`) VALUES('~reid~','~topid~','~rank~','~typename~','~typedir~','$isdefault','$defaultname','$issend','$channeltype', '$tempindex','$templist','$temparticle','default','$namerule','$namerule2','0','0','','','~typename~','0','','','0','0','0','','')";
在typename后面增加一个typename2 也就形成了以下代码:
$queryTemplate = "INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typename2,typedir,isdefault,defaultname,issend,channeltype, tempindex,templist,temparticle,modname,namerule,namerule2,ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`) VALUES('~reid~','~topid~','~rank~','~typename~','~typename2~','~typedir~','$isdefault','$defaultname','$issend','$channeltype', '$tempindex','$templist','$temparticle','default','$namerule','$namerule2','0','0','','','~typename~','0','','','0','0','0','','')";
继续往下找,找到:
$queryTemplate = "INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typename2,typedir,isdefault,defaultname,issend,channeltype, tempindex,templist,temparticle,modname,namerule,namerule2,ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`) VALUES('~reid~','~topid~','~rank~','~typename~','~typename2~','~typedir~','$isdefault','$defaultname','$issend','$channeltype', '$tempindex','$templist','$temparticle','default','$namerule','$namerule2','0','0','','','~typename~','0','','','0','0','0','','')";
依然是在typename 后加一个 typename2 形成了以下代码:
$in_query = "INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typename2,typedir,isdefault,defaultname,issend,channeltype, tempindex,templist,temparticle,modname,namerule,namerule2, ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`) VALUES('$reid','$topid','$sortrank','$typename','$typename2','$typedir','$isdefault','$defaultname','$issend','$channeltype', '$tempindex','$templist','$temparticle','default','$namerule','$namerule2', '$ispart','$corank','$description','$keywords','$seotitle','$moresite','$siteurl','$sitepath','$ishidden','$cross','$crossid','$content','$smalltypes')";
找到:
$sql = str_replace('~typename~',$toptypename,$sql);
下面添加:
$sql = str_replace('~typename2~',$toptypename,$sql);
找到:
$sql = str_replace('~typename~',$v,$sql);
下面添加:
$sql = str_replace('~typename2~',$v,$sql);
打开\dede\catalog_edit.php文件,最好用DW之类的网页编辑器去打开编辑
找到:
typename='$typename',
下面添加:
typename2='$typename2',
找到第二处:
typename='$typename',
下面添加:
typename2=’$typename2′,
找到:
<tr> <td class='bline' height="26" align="center"><font color='red'>栏目名称:</font></td> <td class='bline'><input name="typename" type="text" id="typename" size="30" value="<?php echo $myrow['typename']?>" class="iptxt" /></td> </tr>
下面添加:
<tr> <td class='bline' height="26" align="center"><font color='red'>栏目别名:</font></td> <td class='bline'><input name="typename2" type="text" id="typename2" size="30" value="<?php echo $myrow['typename2']?>" class="iptxt" /></td> </tr>
大功告成!下面是调用方法!
比如你以前栏目的调用方法是:
{dede:channel type='top' row='13'} <li><a href='[field:typeurl/]'>[field:typename/]</a></li> {/dede:channel}
现在就要换成SQL模式的调用方法了
{dede:sql sql="SELECT typename,typedir,typename2 FROM dede_arctype"} <a href="[field:typedir function='str_replace("{cmspath}","",@me)'/]" alt="[field:typename2/]" >[field:typename/]</a> {/dede:sql}
本文地址:https://www.moyublog.com/notes/151.html
本文地址:https://www.moyublog.com/notes/151.html
加入我们:微信:搜索“Moyu-Blog”
版权声明:本文采用[BY-NC-SA]协议进行授权,如无特别说明,转载请注明本文地址!