:详情页增加自定义title的方法!
一、修改数据库结构,其实就是增加个字段
进入后台–>数据库管理–>SQL查询–>在输入框里输入下面SQL语句,并点击“提交查询”
ALTER TABLE `ecs_goods` ADD `goods_title` VARCHAR( 150 ) NOT NULL DEFAULT '' AFTER `goods_name`
二、打开 /admin/templates/goods_info.htm 后台模板文件
找到
<table width="90%" id="general-table" align="center">
在其下面添加
<tr><td class="label">自定义商品页面TITLE</td><td><input type="text" name="goods_title" value="{$goods.goods_title|escape}" size="50" /></td></tr>
三、打开 /admin/goods.php 后台程序文件
找到
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
修改为(注意:一共能找到两处,每处都要修改)
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_title, goods_name_style, goods_sn, " .
找到
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
修改为(注意:一共能找到两处,每处都要修改)
"VALUES ('$_POST[goods_name]','$_POST[goods_title]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
找到
"goods_name = '$_POST[goods_name]', " .
修改为
"goods_name = '$_POST[goods_name]', goods_title='$_POST[goods_title]'," .
四、打开 /goods.php 前台商品程序文件
找到
$smarty->assign('page_title', $position['title']); // 页面标题
修改为
$page_title=!empty($goods['goods_title']) ? $goods['goods_title'] : $position['title'];
$smarty->assign('page_title', $page_title); // 页面标题