dedecms栏目添加字段--栏目自定义字段

时间:2016-12-16 15:03 / 来源:未知 / 作者:酱油 / 点击:

修改织梦栏目,为栏目增加字段,特别记录。

第一我们要进去mysql 数据库里添加字段,自己命名好!比如我下面 添加了一个 栏目搜索关键字字段,当然你字段可以自己新建,找到表dede_arctype(这个是栏目模型的数据库表,前面是你安装的表名)

图片1

在点击添加字段

图片2

添加字段

图片3

到这里数据库 字段添加好了。

接下来我们开始做后台。大家写找到 后台栏目 管理模版!

要更改的 2个 D:\www\dede\templets 模版:catalog_add.htm、catalog_edit.htm

下面就演示一个

图片4

然后添加 字段表单,这个一般大家都会的

我添加的代码是:

<tr> 
<td height="65">栏目搜索关键字:</td>
<td> <textarea name="lanmukeywrod" cols="70" rows="4" id="lanmukeywrod" class="alltxt" ><?php echo $myrow['lanmukeywrod']?></textarea> 
</td>
</tr>

这里大家注意了。表单的name 和id要和添加的 mysql表字段一样,不应的话。还要多写个取值代码。一样的话。默认dedecms会自动取的

然后我们做最后一部,把数据添加进去

大家找到: D:\www\dede\catalog_edit.php

目录可能和大家不一样 也就是后台 里面的 catalog_edit.php,catalog_add.php

catalog_edit.php要改的地方有:

$upquery = "Update `dede_arctype` set
issend='$issend',
sortrank='$sortrank',
typename='$typename',
typedir='$typedir',
isdefault='$isdefault',
defaultname='$defaultname',
issend='$issend',
ishidden='$ishidden',
channeltype='$channeltype',
tempindex='$tempindex',
templist='$templist',
temparticle='$temparticle',
namerule='$namerule',
namerule2='$namerule2',
ispart='$ispart',
corank='$corank',
description='$description',
keywords='$keywords',
moresite='$moresite',
`cross`='$cross',
`content`='$content',
`crossid`='$crossid',
`smalltypes`='$smalltypes'
$uptopsql
where id='$id' ";

sql语句里面添加我们刚才的 字段进去。也就是下面这个代码

看到了这个是添加的:`lanmukeywrod`='$lanmukeywrod'

$upquery = "Update `dede_arctype` set
issend='$issend',
sortrank='$sortrank',
typename='$typename',
typedir='$typedir',
isdefault='$isdefault',
defaultname='$defaultname',
issend='$issend',
ishidden='$ishidden',
channeltype='$channeltype',
tempindex='$tempindex',
templist='$templist',
temparticle='$temparticle',
namerule='$namerule',
namerule2='$namerule2',
ispart='$ispart',
corank='$corank',
description='$description',
keywords='$keywords',
moresite='$moresite',
`cross`='$cross',
`content`='$content',
`crossid`='$crossid',
`smalltypes`='$smalltypes',
`lanmukeywrod`='$lanmukeywrod'
$uptopsql
where id='$id' ";

这个是更新栏目的。catalog_add.php是添加栏目的文件。也是同样的办法,更改地址有:3处。也是同样办法。添加字段信息 到sql里去添加了 lanmukeywrod

$queryTemplate = "insert into`dede_arctype`(reid,topid,sortrank,typename,typedir,isdefault,defaultname,issend,channeltype,
tempindex,templist,temparticle,modname,namerule,namerule2,ispart,corank,description,keywords,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`,`lanmukeywrod`)
Values('~reid~','~topid~','~rank~','~typename~','~typedir~','$isdefault','$defaultname','$issend','$channeltype',
'$tempindex','$templist','$temparticle','default','$namerule','$namerule2','0','0','','','0','','','0','0','0','','','$lanmukeywrod')";

更改后的代码:

$in_query = "insert into`dede_arctype`(reid,topid,sortrank,typename,typedir,isdefault,defaultname,issend,channeltype,
tempindex,templist,temparticle,modname,namerule,namerule2,
ispart,corank,description,keywords,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`,`lanmukeywrod`)
Values('$reid','$topid','$sortrank','$typename','$typedir','$isdefault','$defaultname','$issend','$channeltype',
'$tempindex','$templist','$temparticle','default','$namerule','$namerule2',
'$ispart','$corank','$description','$keywords','$moresite','$siteurl','$sitepath','$ishidden','$cross','$crossid','$content','$smalltypes','$lanmukeywrod')";

下面说下 如何调用到前台

{dede:field.lanmukeywrod/}

在模版里调用这个就可以了!另外,两处后台修改文件分别是后台目录的dede/templets/文件夹中catalog_add.htm和catalog_edit.htm文件。

猜你喜欢

推荐栏目

DEDECMS
DEDECMS

DEDE使用经验和技巧

WordPress
Wordpress

WP使用经验和技巧

Zblog
Zblog

Zblog使用经验和技巧

CSS
CSS

CSS使用经验和技巧

网络资料
网络资料

转载实用网络资料

按键伤人
按键伤人

转载乱七八糟的网络资源

我是酱油
我是酱油

随笔札记 记录生活点滴

本站推荐

百度站内搜索

专业博客主机