zencart对标题,关键字,描述更新和值的判断

zencart对标题,关键字,描述更新和值的判断

标题,关键字,描述对于GOOGLE 和BAIDU等搜索引擎来说是非常重要的.当然对SEO工作人员来说也很看重. 在zencart电子商务网站中的一些修改和对某一个列表页面的某些控制,在zencart程序文件中体现出来.这里就说对zencart对标题,关键字,描述的更新和值的判断.

前面已经说过了对Zencart的一些静态化的设置,这里就不讲了,直接进入文件”include/ includesmodulesmeta_tags.php在这里写着的是所有URL的生成.

以下是对产品页的一些的标题,关键字,描述的一些生成.

// unless otherwise required product_reviews uses the same settings as product_reviews_info and other _info pages

case ‘product_reviews’:

// unless otherwise required product_reviews_info uses the same settings as reviews and other _info pages

case ‘product_reviews_info’:

$review_on = META_TAGS_REVIEW;

//  case ‘product_info’:

case (strstr($_GET[‘main_page’], ‘product_’) or strstr($_GET[‘main_page’], ‘document_’)):

/*

$sql = “select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_price, p.products_tax_class_id, p.product_is_free, p.products_price_sorter,

p.metatags_title_status, p.metatags_products_name_status, p.metatags_model_status, p.metatags_price_status, p.metatags_title_tagline_status,

mtpd.metatags_title, mtpd.metatags_keywords, mtpd.metatags_description from ” . TABLE_PRODUCTS . ” p, ” . TABLE_PRODUCTS_DESCRIPTION . ” pd, ” . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ” mtpd where p.products_status = 1 and p.products_id = ‘” . (int)$_GET[‘products_id’] . “‘ and pd.products_id = p.products_id and pd.language_id = ‘” . (int)$_SESSION[‘languages_id’] . “‘ and mtpd.products_id = p.products_id and mtpd.language_id = ‘” . (int)$_SESSION[‘languages_id’] . “‘”;

*/

$sql= “select pd.products_name, p.products_model, p.products_price_sorter, p.products_tax_class_id,

p.metatags_title_status, p.metatags_products_name_status, p.metatags_model_status,

p.products_id, p.metatags_price_status, p.metatags_title_tagline_status,

pd.products_description, p.product_is_free, p.product_is_call,

mtpd.metatags_title, mtpd.metatags_keywords, mtpd.metatags_description

from (” . TABLE_PRODUCTS . ” p, ” . TABLE_PRODUCTS_DESCRIPTION . ” pd) left join ” . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ” mtpd on mtpd.products_id = p.products_id and mtpd.language_id = ‘” . (int)$_SESSION[‘languages_id’] . “‘

where p.products_id = ‘” . (int)$_GET[‘products_id’] . “‘

and p.products_id = pd.products_id

and pd.language_id = ‘” . (int)$_SESSION[‘languages_id’] . “‘”;

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

if ($product_info_metatags->EOF) {

$meta_tags_over_ride = true;

} else {

// custom meta tags per product

if (!empty($product_info_metatags->fields[‘metatags_keywords’]) or !empty($product_info_metatags->fields[‘metatags_description’])) {

$meta_products_name = ”;

$meta_products_price = ”;

$metatags_keywords = ”;

$meta_products_price = ($product_info_metatags->fields[‘metatags_price_status’] == ‘1’ ? SECONDARY_SECTION . ($product_info_metatags->fields[‘products_price_sorter’] > 0 ? $currencies->display_price($product_info_metatags->fields[‘products_price_sorter’], zen_get_tax_rate($product_info_metatags->fields[‘products_tax_class_id’])) : SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT) : ”);

$meta_products_name .= ($product_info_metatags->fields[‘metatags_products_name_status’] == ‘1’ ? $product_info_metatags->fields[‘products_name’] : ”);

$meta_products_name .= ($product_info_metatags->fields[‘metatags_title_status’] == ‘1’ ? ‘ ‘ . $product_info_metatags->fields[‘metatags_title’] : ”);

$meta_products_name .= ($product_info_metatags->fields[‘metatags_model_status’] == ‘1’ ? ‘ [‘ . $product_info_metatags->fields[‘products_model’] . ‘]’ : ”);

if (zen_check_show_prices() == true) {

$meta_products_name .= $meta_products_price;

}

$meta_products_name .= ($product_info_metatags->fields[‘metatags_title_tagline_status’] == ‘1’ ? PRIMARY_SECTION . TITLE . TAGLINE : ”);

if (!empty($product_info_metatags->fields[‘metatags_description’])) {

// use custom description

$metatags_description = $product_info_metatags->fields[‘metatags_description’];

} else {

// no custom description defined use product_description

$metatags_description = zen_truncate_paragraph(strip_tags(stripslashes($product_info_metatags->fields[‘products_description’])), MAX_META_TAG_DESCRIPTION_LENGTH);

}

$metatags_description = zen_clean_html($metatags_description);

if (!empty($product_info_metatags->fields[‘metatags_keywords’])) {

// use custom keywords

$metatags_keywords = $product_info_metatags->fields[‘metatags_keywords’] . METATAGS_DIVIDER . CUSTOM_KEYWORDS;  // CUSTOM skips categories

} else {

// no custom keywords defined use product_description

$metatags_keywords = KEYWORDS . METATAGS_DIVIDER . $meta_products_name . METATAGS_DIVIDER;

}

define(‘META_TAG_TITLE’, str_replace(‘”‘,”,zen_clean_html($review_on . $meta_products_name)));

define(‘META_TAG_DESCRIPTION’, str_replace(‘”‘,”,zen_clean_html($metatags_description . ‘ ‘)));

define(‘META_TAG_KEYWORDS’, str_replace(‘”‘,”,zen_clean_html($metatags_keywords)));  // KEYWORDS and CUSTOM_KEYWORDS are added above

} else {

// build un-customized meta tag

if (META_TAG_INCLUDE_PRICE == ‘1’ and !strstr($_GET[‘main_page’], ‘document_general’)) {

if ($product_info_metatags->fields[‘product_is_free’] != ‘1’) {

if (zen_check_show_prices() == true) {

$meta_products_price = zen_get_products_actual_price($product_info_metatags->fields[‘products_id’]);

$prod_is_call_and_no_price = ($product_info_metatags->fields[‘product_is_call’] == ‘1’ && $meta_products_price == 0);

$meta_products_price = (!$prod_is_call_and_no_price ? SECONDARY_SECTION . $currencies->display_price($meta_products_price, zen_get_tax_rate($product_info_metatags->fields[‘products_tax_class_id’])) : ”);

}

} else {

$meta_products_price = SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT;

}

} else {

$meta_products_price = ”;

}

if (META_TAG_INCLUDE_MODEL == ‘1’ && zen_not_null($product_info_metatags->fields[‘products_model’])) {

$meta_products_name = $product_info_metatags->fields[‘products_name’] . ‘ [‘ . $product_info_metatags->fields[‘products_model’] . ‘]’;

} else {

$meta_products_name = $product_info_metatags->fields[‘products_name’];

}

$meta_products_name = zen_clean_html($meta_products_name);

$meta_products_description = zen_truncate_paragraph(strip_tags(stripslashes($product_info_metatags->fields[‘products_description’])), MAX_META_TAG_DESCRIPTION_LENGTH);

$meta_products_description = zen_clean_html($meta_products_description);

//产品页

define(‘META_TAG_TITLE’, str_replace(‘”‘,”,$review_on . $meta_products_name . $meta_products_price.  PRIMARY_SECTION.$_SESSION[“cate_2″] . TITLE . TAGLINE));

define(‘META_TAG_DESCRIPTION’, str_replace(‘”‘,”,TITLE . ‘ ‘ . $meta_products_name . SECONDARY_SECTION . $meta_products_description . ‘ ‘));

define(‘META_TAG_KEYWORDS’, str_replace(‘”‘,”,$meta_products_name . METATAGS_DIVIDER . KEYWORDS));

} // CUSTOM META TAGS

} // EOF

break;

以下是zencart电子商务网站的产品一级目录和二级目录

case ‘index’:

// bof: categories meta tags

// run custom categories meta tags

$sql = “select * from ” . TABLE_METATAGS_CATEGORIES_DESCRIPTION . ” mcd where mcd.categories_id = ‘” . (int)$current_category_id . “‘ and mcd.language_id = ‘” . (int)$_SESSION[‘languages_id’] . “‘”;

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

if (!$category_metatags->EOF) {

define(‘META_TAG_TITLE’, str_replace(‘”‘,”,$category_metatags->fields[‘metatags_title’]));

define(‘META_TAG_DESCRIPTION’, str_replace(‘”‘,”,$category_metatags->fields[‘metatags_description’]));

define(‘META_TAG_KEYWORDS’, str_replace(‘”‘,”,$category_metatags->fields[‘metatags_keywords’]));

} else {

// build categories meta tags

// eof: categories meta tags

if ($category_depth == ‘nested’) {

$sql = “select cd.categories_name,cd.categories_id from ” . TABLE_CATEGORIES . ” c, ” . TABLE_CATEGORIES_DESCRIPTION . ” cd where c.categories_id = cd.categories_id and cd.categories_id = ‘” . (int)$current_category_id . “‘ and cd.language_id = ‘” . (int)$_SESSION[‘languages_id’] . “‘ and c.categories_status=1″;

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

if ($category_metatags->EOF) {

$meta_tags_over_ride = true;

} else {

/* 分类左ID*/

define(‘META_TAG_TITLE’, str_replace(‘”‘,”, zen_clean_html($category_metatags->fields[‘categories_name’]) . PRIMARY_SECTION . TITLE . TAGLINE));

define(‘META_TAG_DESCRIPTION’, str_replace(‘”‘,”,TITLE . PRIMARY_SECTION . zen_clean_html($category_metatags->fields[‘categories_name’]) . SECONDARY_SECTION . KEYWORDS));

define(‘META_TAG_KEYWORDS’, str_replace(‘”‘,”,KEYWORDS . METATAGS_DIVIDER . zen_clean_html($category_metatags->fields[‘categories_name’])));

} // EOF

} elseif ($category_depth == ‘products’) {

if (isset($_GET[‘manufacturers_id’]) || ((isset($_GET[‘filter_id’]) && $_GET[‘filter_id’] > 0) && isset($_GET[‘cPath’])) ) {

if ((isset($_GET[‘filter_id’]) && isset($_GET[‘cPath’])) ) {

$include_manufacturers_id = $_GET[‘filter_id’];

} else {

$include_manufacturers_id = $_GET[‘manufacturers_id’];

}

$sql = “select manufacturers_name from ” . TABLE_MANUFACTURERS . ” where manufacturers_id = ‘” . (int)$include_manufacturers_id . “‘”;

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

if ($manufacturer_metatags->EOF) {

$meta_tags_over_ride = true;

} else {

define(‘META_TAG_TITLE’, str_replace(‘”‘,”,$manufacturer_metatags->fields[‘manufacturers_name’] . PRIMARY_SECTION . TITLE . TAGLINE));

define(‘META_TAG_DESCRIPTION’, str_replace(‘”‘,”,TITLE . PRIMARY_SECTION . $manufacturer_metatags->fields[‘manufacturers_name’] . SECONDARY_SECTION . KEYWORDS));

define(‘META_TAG_KEYWORDS’, str_replace(‘”‘,”, $manufacturer_metatags->fields[‘manufacturers_name’] . METATAGS_DIVIDER . KEYWORDS));

} // EOF

} else {

$sql = “select cd.categories_name from ” . TABLE_CATEGORIES . ‘ c, ‘ . TABLE_CATEGORIES_DESCRIPTION . ” cd where c.categories_id = cd.categories_id and cd.categories_id = ‘” . (int)$current_category_id . “‘ and cd.language_id = ‘” . (int)$_SESSION[‘languages_id’] . “‘ and c.categories_status=1″;

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

if ($category_metatags->EOF) {

$meta_tags_over_ride = true;

} else {

//二级分类

define(‘META_TAG_TITLE’, str_replace(‘”‘,”, zen_clean_html($category_metatags->fields[‘categories_name’]) .PRIMARY_SECTION . TITLE . TAGLINE));

define(‘META_TAG_DESCRIPTION’, str_replace(‘”‘,”,TITLE . PRIMARY_SECTION . zen_clean_html($category_metatags->fields[‘categories_name’]) . SECONDARY_SECTION . KEYWORDS));

define(‘META_TAG_KEYWORDS’, str_replace(‘”‘,”,KEYWORDS . METATAGS_DIVIDER . zen_clean_html($category_metatags->fields[‘categories_name’])));

} // EOF

}

} else {

if (isset($_GET[‘manufacturers_id’])) {

$sql = “select manufacturers_name from ” . TABLE_MANUFACTURERS . ” where manufacturers_id = ‘” . (int)$_GET[‘manufacturers_id’] . “‘”;

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

if ($manufacturer_metatags->EOF) {

define(‘META_TAG_TITLE’, TITLE . TAGLINE);

define(‘META_TAG_DESCRIPTION’, TITLE . PRIMARY_SECTION . str_replace(array(“‘”,'”‘),”,strip_tags(HEADING_TITLE)) . SECONDARY_SECTION . KEYWORDS);

define(‘META_TAG_KEYWORDS’, KEYWORDS . METATAGS_DIVIDER . str_replace(array(“‘”,'”‘),”,strip_tags(HEADING_TITLE)));

} else {

define(‘META_TAG_TITLE’, str_replace(‘”‘,”, $manufacturer_metatags->fields[‘manufacturers_name’] . PRIMARY_SECTION . TITLE . TAGLINE));

define(‘META_TAG_DESCRIPTION’, str_replace(‘”‘,”,TITLE . PRIMARY_SECTION . $manufacturer_metatags->fields[‘manufacturers_name’] . SECONDARY_SECTION . KEYWORDS));

define(‘META_TAG_KEYWORDS’, str_replace(‘”‘,”, $manufacturer_metatags->fields[‘manufacturers_name’] . METATAGS_DIVIDER . KEYWORDS));

}

} else {

// nothing custom main page

$meta_tags_over_ride = true;

}

}

} // custom meta tags

break;

你可以对里面的TITLE, KEYWORDS, DESCRIPTION进行修改,以达到自己的目的,不过建议一点程序也不懂的就不要乱改.

Need a translation service?

Please enter your personal details and we will contact you shortly

Words translated by CCJK

146,096,379

Our Client Satisfaction

Rating for previous quarterr

4.00

Over 95% of our clients recommend our language services to others

Copyright © CCJK Technologies Co., Ltd. 2000-2019. All rights reserved.
TOP