zen cart网站优化系列一

---meta设置---

zen cart本身的mate tags设置已经很全面了,包括产品销售页面,产品分类列表页面的关键字以及标题等都完全可以自己定义,如果没有定义则自动调用产品名称、或者分类名称等。
但是针对新产品(index.php?main_page=products_new)、特价 (index.php?main_page=specials)、推荐产品 (index.php?main_page=featured_products)页面在网站后台并不能单独设置,其实这些可以通过修改语言文件中的 meta_tags.php文件来实现。
具体路径如下includes/languages/english/meta_tags.php
在这个文件中找到
define('META_TAG_DESCRIPTION_page_name','');
define('META_TAG_KEYWORDS_page_name','');
define('META_TAG_TITLE_page_name', '');
在其下添加如下代码,并分别写上标题、关键字、描述等。

//products_new
define('META_TAG_DESCRIPTION_PRODUCTS_NEW','35blue.com');
define('META_TAG_KEYWORDS_PRODUCTS_NEW','35blue.com');
define('META_TAG_TITLE_PRODUCTS_NEW', '35blue.com');
//featured_products
define('META_TAG_DESCRIPTION_FEATURED_PRODUCTS','35blue.com');
define('META_TAG_KEYWORDS_FEATURED_PRODUCTS','35blue.com');
define('META_TAG_TITLE_FEATURED_PRODUCTS', '35blue.com');
//specials
define('META_TAG_DESCRIPTION_SPECIALS','35blue.com');
define('META_TAG_KEYWORDS_SPECIALS','35blue.com');
define('META_TAG_TITLE_SPECIALS', '35blue.com');

-----修改首页meta title------

执行以下SQL:
INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function)VALUES

 

(NULL, ‘Homepage title’, ‘HOME_PAGE_TITLE’, ‘你的网站标题title’, ‘set the home page title’, 1,210, NOW(), NOW(), NULL, NULL),
(NULL, ‘Homepage keywords’, ‘HOME_PAGE_META_KEYWORDS’, ‘你的关键词 keywords’, ‘set the home page keywords’, 1,211, NOW(), NOW(), NULL, NULL),
(NULL, ‘Homepage description’, ‘HOME_PAGE_META_DESCRIPTION’, ‘l你的网站描述 description’, ‘set the home page description’, 1,212, NOW(), NOW(), NULL, NULL);

接着对应修改includes/languages/english/meta_tags.php的内容:

// Home Page Only:
define(‘HOME_PAGE_META_DESCRIPTION’, HOME_PAGE_META_DESCRIPTION);
define(‘HOME_PAGE_META_KEYWORDS’, HOME_PAGE_META_KEYWORDS);
define(‘HOME_PAGE_TITLE’, HOME_PAGE_TITLE);
// NOTE: If HOME_PAGE_TITLE is left blank (default) then TITLE and SITE_TAGLINE will be used instead.
define(‘HOME_PAGE_TITLE’, HOME_PAGE_TITLE); // usually best left blank
以上添加后就可以在后台直接编辑你的标题,关键词和描述

重新登录后在 conficuration-my store 里面进行设置

------zencart系统其它页面meta修改说明文档-------

meta的修改
修改目录页meta
   目录有的只有一级目录,有的会有二级目录,所以我们在修改目录的时候要考虑到二级目录,这样无论是一级目录还是二级目录都有修改到
  在includes/modules/meta_tages.php中找到
大概从130行开始
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 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 {
      这里要改为我们需要的目录页meta
        define('META_TAG_TITLE', str_replace('"','', zen_clean_html($category_metatags->fields['categories_name']) . ' - sale cheap Ed Hardy in online Ed Hardy Shop' . TAGLINE));
        define('META_TAG_DESCRIPTION', str_replace('"','', zen_clean_html($category_metatags->fields['categories_name']) . ' are sells well in ed hardy shop,the newest and popular ' . zen_clean_html($category_metatags->fields['categories_name']) . ' are cheap ed hardy and good quality fashion show in Edhardy-us.com.'));
        define('META_TAG_KEYWORDS', str_replace('"','','ed hardy clothing,ed hardy clothes,ed hardy sale,' . zen_clean_html($category_metatags->fields['categories_name']) . ',ed hardy shirts'));
      } // 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 {

这里也要改为我们需要的meta
          define('META_TAG_TITLE', str_replace('"','', zen_clean_html($category_metatags->fields['categories_name']) . ' - sale cheap Ed Hardy in online Ed Hardy Shop' . TAGLINE));
          define('META_TAG_DESCRIPTION', str_replace('"','', zen_clean_html($category_metatags->fields['categories_name']) . ' are sells well in ed hardy shop,the newest and popular ' . zen_clean_html($category_metatags->fields['categories_name']) . ' are cheap ed hardy and good quality fashion show in Edhardy-us.com.'));
          define('META_TAG_KEYWORDS', str_replace('"','','ed hardy clothing,ed hardy clothes,ed hardy sale,' . zen_clean_html($category_metatags->fields['categories_name']) . ',ed hardy shirts'));
        } // 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;
  // eof: categories meta tags
上面两个一个是一级目录的meta,一个二级目录的meta
3、修改产品页目录的meta
    在includes/modules/meta_tages.php中找到(335-337)
      define('META_TAG_TITLE', str_replace('"','', $meta_products_name .' - '.$meta_products_model.' | air max'.$meta_products_price. ' airmaxsky.com '. TAGLINE));
      define('META_TAG_DESCRIPTION', str_replace('"','',$meta_products_name .' - '.$meta_products_model.' sells well in airmaxsky.com.Air Max online store support 24/7 service.'.$meta_categories_name .' - '.$meta_products_name.' is the top air max shoes.' ));
      define('META_TAG_KEYWORDS', str_replace('"','',$meta_products_name));
这三行,在文件335-337,将他们改为我们需要的meta

注意:
       1、meta改完后要检查下,记得在改首页时,文本是不能换行的
       2、产品页和目录页的meta也可以在后台添加目录或产品中修改,如果在后台修改,其优先级别最高


在二级目录页中可通过面包线(breakcrumb)来设置类别名。breakcrumb.php在includes/classes中有个function trail($separator = '  ')函数,可在这下再创建一个新的函数function trailMeta($separator = '  ')里面的内容代码跟前面的那个是一样的,如果想改什么可以在这里改动。

产品页中的类别名
  在235行左右有个sql语句,里面添加p.master_categories_id,然后在下面大约315行左右
    define('META_TAG_TITLE', str_replace('"','',$meta_products_name . $meta_products_price . ' | Cheap Bags'));
      define('META_TAG_DESCRIPTION', str_replace('"','',$meta_products_name . ' is a best sellig ' . zen_clean_html    ($category_metatags->fields['categories_name']) . '.Cheap ' . $meta_products_name . ' sale 30% OFF.FREE     Shipping for every Replica Bags!'));
      define('META_TAG_KEYWORDS', str_replace('"','',$meta_products_name . ','.zen_clean_html($category_metatags-    >fields['categories_name']).',Fashion Bags,Replica Bags'));
前面添加     $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);

 
------------

你可能感兴趣的:(zen cart网站优化系列一)