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