zen cart产品页面伪静态后-c-.html,zencart1.5.1产品页url的修改

Zencart 产品页面url的修改(二级分类_一级分类_所属分类_产品模型.html)

1,修改根目录下的.htaccess

RewriteRule ^(.*)_(.*).html$ index\.php?main_page=product_info&products_model=$2&%{QUERY_STRING} [L]

2,修改includes/ini_includes/init_category_path.php

if(zen_not_null($_GET['products_model'])){

$sql="select products_id from ". TABLE_PRODUCTS." where products_model='".$_GET['products_model']."'";

$pid= $db->Execute($sql);

$_GET['products_id']=$pid->fields['products_id'];

}

3,修改文件includes/classes/seo_url.php

case 'products_id':

switch(true) {

case ($page == FILENAME_PRODUCT_REVIEWS):

$url = $this->make_url($page, $this->get_product_name($p2[1]), 'products_id_review',$p2[1], '.html', $separator);

break;

case ($page == FILENAME_PRODUCT_REVIEWS_INFO):

$url = $this->make_url($page, $this->get_product_name($p2[1]), 'products_id_review_info', $p2[1], '.html', $separator);

break;

//

case ($page == FILENAME_PRODUCT_INFO && !$this->is_attribute_string($params)):

case ($page == FILENAME_PRODUCT_INFO):

case ($page == 'product_free_shipping_info'):

case ($page == 'product_music_info'):

case ($page == 'document_product_info'):

case ($page == 'document_general_info'):

default:

;

$url = $this->make_url($page, strtolower($this->get_product_cate_name($p2[1])).'_', '', strtolower($this->get_product_model($p2[1])), '.html', $separator);

break;

} # end switch

break;

添加下面函数:

//bof zhjhqk

function get_product_model($pID){

$sql="select products_model from ". TABLE_PRODUCTS." where products_id=".$pID;

$result = $this->db->Execute($sql, false, true, 43200);

$pModel = $this->strip($result->fields['products_model']);

return $pModel;

}

function get_product_cate_name($pID){

$sql="select master_categories_id from ".TABLE_PRODUCTS. " where products_id='".$pID."'";

$result = $this->db->Execute($sql, false, true, 43200);

$c_id = $this->strip($result->fields['master_categories_id']);

$path = array();

$this->get_zhjhqk_parent_categories_path($path, $c_id);

return $path[1].'_'.$path[0].'_'.$path[sizeof($path)-1];

}

function get_zhjhqk_parent_categories_path(&$path, $categories_id, &$cPath = array())

{

$sql = 'SELECT c.parent_id AS p_id, cd.categories_name AS name ' .

'FROM ' . TABLE_CATEGORIES . ' c ' .

'LEFT JOIN ' . TABLE_CATEGORIES_DESCRIPTION . ' cd ' .

'ON c.categories_id=cd.categories_id ' .

'AND cd.language_id=\'' . (int)$this->languages_id . '\'' .

'WHERE c.categories_id=\'' . (int)$categories_id . '\'';

$parent = $this->db->Execute($sql, false, true, 43200);

while (!$parent->EOF) {

// Recurse if the parent id is not empty or equal the passed categories id

if ($parent->fields['p_id'] != 0 && $parent->fields['p_id'] != $categories_id) {

$this->get_zhjhqk_parent_categories_path($path, $parent->fields['p_id'], $cPath);

}

// Add category id to cPath and name to path

$cPath[sizeof($cPath)] = $categories_id;

$path[sizeof($path)] = $this->strip($parent->fields['name']);

$parent->MoveNext();

}

}

//eof zhjhqk

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值