如何自定义ecshop品牌页标题

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家

在百度里边搜索,有很多有详细的步骤,但是我试了下,行不通。这里跪求 详细步骤,最好是发页面代码给我,我只要实行sql语句就好

回答:
按照百度搜索的步骤来,我弄了半天,没弄出来,哎

思路:
1) 在数据表 ecs_brand里增加一个字段 define_title
2) 修改 admin/templates/brand_info.htm,在表单里增加一个 字段
3)修改 admin/brand.php, 保存这个字段值到数据库中
4)修改前台的 /brand.php 将 page_title 重新赋值 $brand_info['define_title']

有些功能的修改还是得需要一定php基础的,如果没基础的话,即使教程没问题,照着做也做不对。

貌似有人发过这个,我都测试成功啦...
1.运行下,注意表前缀(ecs)
  1. ALTER TABLE 'ecs_brand' ADD 'brand_keywords' VARCHAR( 255 ) NOT NULL AFTER 'brand_desc';
  2. ALTER TABLE 'ecs_brand' ADD 'brand_description' VARCHAR( 255 ) NOT NULL AFTER 'brand_desc';
复制代码


2.\admin\templates\brand_info.htm 添加布局,查找如下:
  1. <tr>
  2. <td>{$lang.sort_order}</td>
  3. <td><input type="text" name="sort_order" maxlength="40" size="15" value="{$brand.sort_order}" /></td>
  4. </tr>
复制代码


底下添加:
  1. <tr>
  2. <td>关键词:</td>
  3. <td><input type="text" name="brand_keywords" maxlength="200" value="{$brand.brand_keywords|escape}" /></td>
  4. </tr>
  5. <tr>
  6. <td>描述:</td>
  7. <td><textarea name="brand_description" cols="60" rows="4" >{$brand.brand_description}</textarea></td>
  8. </tr>
复制代码


3.\admin\brand.php将以下修改:
  1. $sql = "INSERT INTO ".$ecs->table('brand')."(brand_name, site_url, brand_desc, brand_logo, is_show, sort_order) ".
  2. "VALUES ('$_POST[brand_name]', '$site_url', '$_POST[brand_desc]', '$img_name', '$is_show', '$_POST[sort_order]')";
  3. $db->query($sql);
复制代码
修改为:
  1. $sql = "INSERT INTO ".$ecs->table('brand')."(brand_name, site_url, brand_desc, brand_logo, is_show, sort_order, brand_keywords, brand_description) ".
  2. "VALUES ('$_POST[brand_name]', '$site_url', '$_POST[brand_desc]', '$img_name', '$is_show', '$_POST[sort_order]', '$_POST[brand_keywords]', '$_POST[brand_description]')";
  3. $db->query($sql);
复制代码

将:
  1. $sql = "SELECT brand_id, brand_name, site_url, brand_logo, brand_desc, brand_logo, is_show, sort_order ".
  2. "FROM " .$ecs->table('brand'). " WHERE brand_id='$_REQUEST[id]'";
  3. $brand = $db->GetRow($sql);
复制代码

修改为:
  1. $sql = "SELECT brand_id, brand_name, site_url, brand_logo, brand_desc, brand_logo, is_show, sort_order, brand_keywords, brand_description ".
  2. "FROM " .$ecs->table('brand'). " WHERE brand_id='$_REQUEST[id]'";
  3. $brand = $db->GetRow($sql);
复制代码

  1. $img_name = basename($image->upload_image($_FILES['brand_logo'],'brandlogo'));
  2. $param = "brand_name = '$_POST[brand_name]',site_url='$site_url', brand_desc='$_POST[brand_desc]', is_show='$is_show', sort_order='$_POST[sort_order]' ";
复制代码
修改为:
  1. $img_name = basename($image->upload_image($_FILES['brand_logo'],'brandlogo'));
  2. $param = "brand_name = '$_POST[brand_name]',site_url='$site_url', brand_desc='$_POST[brand_desc]', is_show='$is_show', sort_order='$_POST[sort_order]', brand_keywords='$_POST[brand_keywords]', brand_description='$_POST[brand_description]' ";
复制代码

4.

/brand.php


  1. $smarty->assign(‘keywords’, htmlspecialchars($brand_info['brand_desc']));
  2. $smarty->assign(‘description’, htmlspecialchars($brand_info['brand_desc']));
复制代码
修改为:
  1. $smarty->assign('keywords', htmlspecialchars($brand_info['brand_keywords']));
  2. $smarty->assign('description', htmlspecialchars($brand_info['brand_description']));
复制代码

测试下看看

ECSHOP学习资料:http://www.phpally.com

搜索 自定义URL

4楼 正解