网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > ZenCart
User Name
Password
 
FAQ Members List Calendar Cheap Glasses Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1   IP: 122.195.220.37
Old 2012-12-21, 07:23 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default zen-cart的Meta信息部署

网页的title和网页的meta信息是一个页面的内容的重要的组成部分。zen cart中,对产品目录和产品页面分别设置了两张表存储这些meta信息,产品目录的meta信息如果没有指定,title就是目录名称,keyword 就是预定规则,description从目录描述中抓取一段字符填充。这个很好理解。

产品的meta信息设置就不太一样一点,主要是针对title进行了特别设置,在products表中,有 metatags_products_name_status和metatags_title_status和 metatags_model_status和metatags_price_status和 metatags_title_tagline_status这几个字段,这些字段都是控制是否要把相对应的值在title中显示,当在 meta_tags_products_description表中写入了对应产品的meta_title信息的时候,同时设置了 metatags_title_status为1,表示用指定的meta_title作为页面的标题,当然了,其它的值是否要在标题中显示,完全取决于设 置的状态(顺序是产品名称 自定义title …. ),一般情况,当自定义了标题,其它的值就不需要添加了,通过程序修改这些东西的时候,我通常会做如下的sql语句:

$db->Execute(‘update products set metatags_products_name_status=0, metatags_title_status=1, metatags_model_status=0, metatags_price_status=0, metatags_price_status=0 where products_id=’.$pid);

只使用指定的信息作为标题,其它的垃圾一律清除。

至于产品页面的keyword和description,跟目录页面的逻辑是一样的。

title的信息一定是最重要的,严格来说,它不是meta信息,meta信息是指那些以meta标签引入的信息,这些信息叫做元数据,是一种自我 描述的信息,这些信息的引入,给网页提供了一个自我描述的机会,让它向搜索引擎展示它的作用,曾经,这个很被看重。目前来说,这段信息的作用已经被降低, 特别是针对google, 它非常看重网页提供的真实可见的内容,而不是一些用户看不到自我鼓吹的描述信息,当然并不是说googe不参考这些信息,目前来说,基本可以肯定,用户真 实可见的内容比这些meta信息更加重要,如果真实可见的内容与meta信息毫无关联,那么就会有作弊的嫌疑,前篇一律或者用同一个模具的meta描述, 估计作用不大,取而代之的可能是真实可见的描述信息,去查看一下google的收录和对比一下meta描述信息可以证明这点。

我见过的,我认为最好的做法,当然是针对google搜索引擎的做法,是在产品描述的最前面写一段针对这个产品的大概两三百字的原创描述,接下来再 粘贴伪原创内容,然后用程序抓取这两三百字作为meta描述,这样真实内容和自我鼓吹一致,这个非常符合google的胃口,有案例证明这点。

接下来分析一下zen cart整站的meta信息是如何被设置的,一共设计到三个文件,includes\languages\english\meta_tags.php和 includes\modules\meta_tags.php和includes\templates\模板名称\common \html_header.php。其中includes\languages\english\meta_tags.php文件是在语言包的全局文件比 如language中的english.php文件中的require(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . ‘/’ . $template_dir_select . ‘meta_tags.php’);语句加载进来的。

includes\languages\english\meta_tags.php文件定义了一些全局的信息,比如TITLE、 SITE_TAGLINE、CUSTOM_KEYWORDS,其中如果TITLE和CUSTOM_KEYWORDS如果设置了值,那么每个页面的 title和description都带这个尾巴。接下来定义首页的信息,然后分别是定义ezpage、指定页面(比如main_page=specials)的信息, 还有META_TAGS_REVIEW、PRIMARY_SECTION、SECONDARY_SECTION、TERTIARY_SECTION和 METATAGS_DIVIDER常量,最后是ROBOTS_PAGES_TO_SKIP,这个常量定义了要添加 的页面。

当加载includes\templates\模板名称\common\html_header.php文件时,includes\modules \meta_tags.php文件会首先被加载进来,这个文件首先针对页面,如果在includes\languages\english \meta_tags.php中指定了特定页面的信息,这里修正它。然后是自动构建meta信息。

可以看到,每个页面的title和meta信息都是可以自定义的。

接下来重点看看产品的meta信息部署逻辑:



// 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; // 当进入到产品的review页面时,这是一个先导字符串
// case ‘product_info’:
case (strstr($_GET['main_page'], ‘product_’) or strstr($_GET['main_page'], ‘document_’)):
$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);
// 没有指定特定的meta信息,用$meta_tags_over_ride标志,最后应用默认的,观察sql语句,它是left join,所以这里一定进入else
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'] : ”);
// 检查是否加入指定的title信息
$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;
}
// 还考虑加tagline,真是想疯了
$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 没有指定就把$meta_products_name加入进来,可能包含型号等信息,关键看状态
$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
// 如果关键 和 描述都没有设置,将自动生成相关信息,注意这些常量META_TAG_INCLUDE_PRICE,是可以后台指定的
} 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 . 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;

注意$review_on = META_TAGS_REVIEW;这段代码是当访问的是产品的具体review时,为了避免标题重复,在前面加了一个前导字符,比如默认是 “Review:”, 默认有两种页面,product_reviews和product_reviews_info。
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 12:16 PM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.