Thread: Meta Tag Delima

Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2007
    Posts
    107
    Plugin Contributions
    0

    Default Meta Tag Delima

    From reading the forums, I've managed to customize my main/home page meta tags using the meta_tags.php files. I'm also doing just fine assigning page-specific meta tags through Admin for all the others.

    However, I noticed tonight that Zen is automatically tacking the keywords that I had set for the main/home page meta tag onto the end of each of the page-specific keyword metas. Is there a way to stop it from doing this? It doesn't add anything from the main/home page metas on to the page-specific title or description, just the keywords list.

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Meta Tag Delima

    However, I noticed tonight that Zen is automatically tacking the keywords that I had set for the main/home page meta tag onto the end of each of the page-specific keyword metas. Is there a way to stop it from doing this? It doesn't add anything from the main/home page metas on to the page-specific title or description, just the keywords list.
    This should be a good thing - If you have selected your main keywords to be as general descriptions and the page specific to finely detail describe this product/category they should be complementary and not repetative.

  3. #3
    Join Date
    Feb 2007
    Posts
    107
    Plugin Contributions
    0

    Default Re: Meta Tag Delima

    Very true, but to give an example of why it isn't good for this site (or maybe I'm over looking something?):

    My main page is a general intro to all of the pet products we offer, with emphasis (and meta tags) focusing on clothes, beds, and collars.
    Now if I'm creating a page to sell a crate, it doesn't seem like a good thing to have "clothes" or "bed" in the keywords when they are not mentioned in the crate's meta title, description, nor in the page content.

  4. #4
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Meta Tag Delima

    Try this:
    1. Copy /includes/modules/meta_tags.php to /includes/modules/YOURTEMPLATE/meta_tags.php

    2. Edit the /includes/modules/YOURTEMPLATE/meta_tags.php file.
    Around line 93 you'll see this:
    Code:
      case 'index':
    Insert the following BEFORE that line:
    Code:
      case ($this_is_home_page):
      define('META_TAG_TITLE', (defined('NAVBAR_TITLE') ? NAVBAR_TITLE . PRIMARY_SECTION : '') . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', HOME_PAGE_META_DESCRIPTION);
      define('META_TAG_KEYWORDS', HOME_PAGE_META_KEYWORDS);
      break;
    Then go to your /includes/languages/english/ folder and copy meta_tags.php to YOURTEMPLATE/meta_tags.php
    and add these to the file:
    Code:
    define('HOME_PAGE_META_DESCRIPTION', 'My Home Page description metatags');
    define('HOME_PAGE_META_KEYWORDS','My home page keywords here');
    Now you can customize your home-page keywords till your heart's content.
    The rest of the pages will operate based on the selected category's metatags or the selected product's metatags.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Feb 2007
    Posts
    107
    Plugin Contributions
    0

    Default Re: Meta Tag Delima

    I suspect that I have done something wrong in my earlier customizations of the meta_tags.php (in modules). I already had it to where I could customize everything seperately, but the keyword issue was there. I applied the code you provided (many thanks BTW!) and I still have those pesky additional keywords in the meta tags.
    I forgot to add that they are only showing up in the individual products' meta keywords though, not in the category metas nor the subcategory metas. Here is my custom meta_tags.php including the change you suggested (I removed the header for this post):

    Code:
    <?php
    if (!defined('IS_ADMIN_FLAG')) {
      die('Illegal Access');
    }
    // This should be first line of the script:
    $zco_notifier->notify('NOTIFY_MODULE_START_META_TAGS');
    
    // Add tertiary section to site tagline
    if (strlen(SITE_TAGLINE) > 1) {
      define('TAGLINE', TERTIARY_SECTION . SITE_TAGLINE);
    } else {
      define('TAGLINE', '');
    }
    
    $review_on = "";
    $keywords_string_metatags = "";
    $meta_tags_over_ride = false;
    if (!defined('METATAGS_DIVIDER')) define('METATAGS_DIVIDER', ' ');
    
    // Get all top category names for use with web site keywords
    $sql = "select cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = 0 and c.categories_id = cd.categories_id and cd.language_id='" . (int)$_SESSION['languages_id'] . "' and c.categories_status=1";
    $keywords_metatags = $db->Execute($sql);
    while (!$keywords_metatags->EOF) {
    //  $keywords_string_metatags .= $keywords_metatags->fields['categories_name'] . METATAGS_DIVIDER;
      $keywords_metatags->MoveNext();
    }
    define('KEYWORDS', str_replace('"','',zen_clean_html($keywords_string_metatags) . CUSTOM_KEYWORDS));
    
    // Get different meta tag values depending on main_page values
    switch ($_GET['main_page']) {
      case 'advanced_search':
      case 'account_edit':
      case 'account_history':
      case 'account_history_info':
      case 'account_newsletters':
      case 'account_notifications':
      case 'account_password':
      case 'address_book':
      define('META_TAG_TITLE', HEADING_TITLE . PRIMARY_SECTION . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . NAVBAR_TITLE_1 . SECONDARY_SECTION . KEYWORDS);
      define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . NAVBAR_TITLE_1);
      break;
    
      case 'address_book_process':
      define('META_TAG_TITLE', NAVBAR_TITLE_ADD_ENTRY . PRIMARY_SECTION . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . NAVBAR_TITLE_ADD_ENTRY . SECONDARY_SECTION . KEYWORDS);
      define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . NAVBAR_TITLE_ADD_ENTRY);
      break;
    
      case 'advanced_search_result':
      case 'password_forgotten':
      define('META_TAG_TITLE', NAVBAR_TITLE_2 . PRIMARY_SECTION . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . NAVBAR_TITLE_2 . SECONDARY_SECTION . KEYWORDS);
      define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . NAVBAR_TITLE_2);
      break;
    
      case 'checkout_confirmation':
      case 'checkout_payment':
      case 'checkout_payment_address':
      case 'checkout_shipping':
      case 'checkout_success':
      case 'create_account_success':
      define('META_TAG_TITLE', HEADING_TITLE . PRIMARY_SECTION . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . HEADING_TITLE . SECONDARY_SECTION . KEYWORDS);
      define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . HEADING_TITLE);
      break;
    
    case ($this_is_home_page):
      define('META_TAG_TITLE', (defined('NAVBAR_TITLE') ? NAVBAR_TITLE . PRIMARY_SECTION : '') . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', HOME_PAGE_DESCRIPTION);
      define('META_TAG_KEYWORDS', CUSTOM_KEYWORDS);
      break;
      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 {
            define('META_TAG_TITLE', str_replace('"','',$category_metatags->fields['categories_name'] . PRIMARY_SECTION . TITLE . TAGLINE));
            define('META_TAG_DESCRIPTION', str_replace('"','',TITLE . PRIMARY_SECTION . $category_metatags->fields['categories_name'] . SECONDARY_SECTION . KEYWORDS));
            define('META_TAG_KEYWORDS', str_replace('"','',KEYWORDS . METATAGS_DIVIDER . $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('"','',$category_metatags->fields['categories_name'] . PRIMARY_SECTION . TITLE . TAGLINE));
              define('META_TAG_DESCRIPTION', str_replace('"','',TITLE . PRIMARY_SECTION . $category_metatags->fields['categories_name'] . SECONDARY_SECTION . KEYWORDS));
              define('META_TAG_KEYWORDS', str_replace('"','',KEYWORDS . METATAGS_DIVIDER . $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', HOME_PAGE_DESCRIPTION);
              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
    
      case 'popup_image':
      $meta_products_name = str_replace('"','',zen_clean_html($products_values->fields['products_name']));
      define('META_TAG_TITLE', $meta_products_name . PRIMARY_SECTION . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . $meta_products_name . SECONDARY_SECTION . KEYWORDS);
      define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . $meta_products_name);
      break;
    
      case 'popup_image_additional':
      $meta_products_name = str_replace('"','',zen_clean_html($products_values->fields['products_name']));
      define('META_TAG_TITLE', $meta_products_name . PRIMARY_SECTION . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . $meta_products_name . SECONDARY_SECTION . KEYWORDS);
      define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . $meta_products_name);
      break;
    
      case 'popup_search_help':
      define('META_TAG_TITLE', HEADING_SEARCH_HELP . PRIMARY_SECTION . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . HEADING_SEARCH_HELP . SECONDARY_SECTION . KEYWORDS);
      define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . HEADING_SEARCH_HELP);
      break;
    
      // 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,
                                          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 : '');
    Continued below due to lack of space:........................

  6. #6
    Join Date
    Feb 2007
    Posts
    107
    Plugin Contributions
    0

    Default Re: Meta Tag Delima

    Code:
    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('"','',$review_on . $meta_products_name));
          define('META_TAG_DESCRIPTION', str_replace('"','',$metatags_description . ' '));
          define('META_TAG_KEYWORDS', str_replace('"','',$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']);
    $meta_products_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);
    
     $products_description = zen_truncate_paragraph(strip_tags(stripslashes($product_info_metatags->fields['products_description'])), MAX_META_TAG_DESCRIPTION_LENGTH);
    
          $products_description = zen_clean_html($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 . $products_description . ' '));
          define('META_TAG_KEYWORDS', str_replace('"','',$meta_products_name . METATAGS_DIVIDER . KEYWORDS));
    
        } // CUSTOM META TAGS
      } // EOF
      break;
    
      case 'product_reviews_info_OFF':
     $sql = "select rd.reviews_text, r.reviews_rating, r.reviews_id, r.customers_name, p.products_id, p.products_price, p.products_tax_class_id, p.products_model, pd.products_name, p.product_is_free from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where r.reviews_id = '" . (int)$_GET['reviews_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "' and r.products_id = p.products_id and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = '". (int)$_SESSION['languages_id'] . "'";
      $review_metatags = $db->Execute($sql);
      if ($review_metatags->EOF) {
        $meta_tags_over_ride = true;
      } else {
        if (META_TAG_INCLUDE_PRICE == '1') {
          if ($review_metatags->fields['product_is_free'] != '1') {
            $meta_products_price = zen_get_products_actual_price($review_metatags->fields['products_id']);
    $meta_products_price = SECONDARY_SECTION . $currencies->display_price($meta_products_price, zen_get_tax_rate($review_metatags->fields['products_tax_class_id']));
          } else {
            $meta_products_price = SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT;
          }
        } else {
          $meta_products_price = '';
        }
    
        if (zen_not_null($review_metatags->fields['products_model'])) {
    $meta_products_name = $review_metatags->fields['products_name'] . ' [' . $review_metatags->fields['products_model'] . ']';
        } else {
          $meta_products_name = $review_metatags->fields['products_name'];
        }
    
        $meta_products_name = zen_clean_html($meta_products_name);
    
        $review_text_metatags = substr(strip_tags(stripslashes($review_metatags->fields['reviews_text'])), 0, 60);
        $reviews_rating_metatags = SUB_TITLE_RATING . ' ' . sprintf(TEXT_OF_5_STARS, $review_metatags->fields['reviews_rating']);
    define('META_TAG_TITLE', str_replace('"','',$meta_products_name . $meta_products_price . PRIMARY_SECTION . TITLE . TERTIARY_SECTION . NAVBAR_TITLE));
    define('META_TAG_DESCRIPTION', str_replace('"','',TITLE . PRIMARY_SECTION . NAVBAR_TITLE . SECONDARY_SECTION . $meta_products_name . SECONDARY_SECTION . $review_metatags->fields['customers_name'] . SECONDARY_SECTION . $review_text_metatags . ' ' . SECONDARY_SECTION . $reviews_rating_metatags));
    define('META_TAG_KEYWORDS', str_replace('"','',KEYWORDS . METATAGS_DIVIDER . $meta_products_name . METATAGS_DIVIDER . $review_metatags->fields['customers_name'] . METATAGS_DIVIDER . $reviews_rating_metatags));
      } // EOF
      break;
    
      default:
      define('META_TAG_TITLE', (defined('NAVBAR_TITLE') ? NAVBAR_TITLE . PRIMARY_SECTION : '') . TITLE . TAGLINE);
    define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . (defined('NAVBAR_TITLE') ? NAVBAR_TITLE : '' ) . SECONDARY_SECTION . KEYWORDS);
      define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . (defined('NAVBAR_TITLE') ? NAVBAR_TITLE : '' ) );
    }
    
    // meta tags override due to 404, missing products_id, cPath or other EOF issues
    if ($meta_tags_over_ride == true) {
      define('META_TAG_TITLE', (defined('NAVBAR_TITLE') ? NAVBAR_TITLE . PRIMARY_SECTION : '') . TITLE . TAGLINE);
    define('META_TAG_DESCRIPTION', TITLE . (defined('NAVBAR_TITLE') ? PRIMARY_SECTION . NAVBAR_TITLE : '') . SECONDARY_SECTION . KEYWORDS);
      define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . (defined('NAVBAR_TITLE') ? NAVBAR_TITLE : ''));
    }
    
    // This should be last line of the script:
    $zco_notifier->notify('NOTIFY_MODULE_END_META_TAGS');
    ?>
    What have I done wrong?

  7. #7
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Meta Tag Delima

    Quote Originally Posted by DrByte View Post
    Try this:
    1. Copy /includes/modules/meta_tags.php to /includes/modules/YOURTEMPLATE/meta_tags.php

    2. Edit the /includes/modules/YOURTEMPLATE/meta_tags.php file.
    Around line 93 you'll see this:
    Code:
      case 'index':
    Insert the following BEFORE that line:
    Code:
      case ($this_is_home_page):
      define('META_TAG_TITLE', (defined('NAVBAR_TITLE') ? NAVBAR_TITLE . PRIMARY_SECTION : '') . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', HOME_PAGE_META_DESCRIPTION);
      define('META_TAG_KEYWORDS', HOME_PAGE_META_KEYWORDS);
      break;
    Then go to your /includes/languages/english/ folder and copy meta_tags.php to YOURTEMPLATE/meta_tags.php
    and add these to the file:
    Code:
    define('HOME_PAGE_META_DESCRIPTION', 'My Home Page description metatags');
    define('HOME_PAGE_META_KEYWORDS','My home page keywords here');
    Now you can customize your home-page keywords till your heart's content.
    The rest of the pages will operate based on the selected category's metatags or the selected product's metatags.
    But ... you did it like this:
    Code:
    case ($this_is_home_page):
      define('META_TAG_TITLE', (defined('NAVBAR_TITLE') ? NAVBAR_TITLE . PRIMARY_SECTION : '') . TITLE . TAGLINE);
      define('META_TAG_DESCRIPTION', HOME_PAGE_DESCRIPTION);
      define('META_TAG_KEYWORDS', CUSTOM_KEYWORDS);
      break;
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Feb 2007
    Posts
    107
    Plugin Contributions
    0

    Default Re: Meta Tag Delima

    I'm sorry, I didn't realize the name change would make a difference, and I had already had that define by that name in my file. I re-did it exactly as you said, and it *did* work just fine.

    The only problem now is that it's putting the phrase "Custom Keywords" at the end of the keywords list as such:

    "dog bowtie, bow tie for dogs, black, red, large, small CUSTOM_KEYWORDS"

    The EXACT line I have in the meta_tags.php in the english folder is:

    define('HOME_PAGE_META_KEYWORDS', 'dog clothes, accessories, dog supplies, collars, dog beds, small dog carriers, travel, pet, puppy');

    And the EXACT code in my meta_tags.php file in modules:

    case ($this_is_home_page):
    define('META_TAG_TITLE', (defined('NAVBAR_TITLE') ? NAVBAR_TITLE . PRIMARY_SECTION : '') . TITLE . TAGLINE);
    define('META_TAG_DESCRIPTION', HOME_PAGE_DESCRIPTION);
    define('META_TAG_KEYWORDS', HOME_PAGE_META_KEYWORDS);
    break;


    I used the Developer's Tool Kit in Admin to see if I could find where the "CUSTOM_KEYWORDS" might be located, and here is where it's showing up:

    /includes/languages/english/meta_tags.php
    Line #12 : //define('CUSTOM_KEYWORDS', 'ecommerce, open source, shop, online shopping');

    /includes/languages/english.php
    Line #16 : define('CUSTOM_KEYWORDS', 'ecommerce, open source, shop, online shopping');

    includes/modules/custom/meta_tags.php
    Line #51 : define('KEYWORDS', str_replace('"','',zen_clean_html($keywords_string_metatags) . CUSTOM_KEYWORDS));

    Line #243 : $metatags_keywords = $product_info_metatags->fields['metatags_keywords'] . METATAGS_DIVIDER . CUSTOM_KEYWORDS; // CUSTOM skips categories

    Line #251 : define('META_TAG_KEYWORDS', str_replace('"','',$metatags_keywords)); // KEYWORDS and CUSTOM_KEYWORDS are added above

    /includes/modules/meta_tags.php
    Line #51 : define('KEYWORDS', str_replace('"','',zen_clean_html($keywords_string_metatags) . CUSTOM_KEYWORDS));

    Line #238 : $metatags_keywords = $product_info_metatags->fields['metatags_keywords'] . METATAGS_DIVIDER . CUSTOM_KEYWORDS; // CUSTOM skips categories

    Line #246 : define('META_TAG_KEYWORDS', str_replace('"','',$metatags_keywords)); // KEYWORDS and CUSTOM_KEYWORDS are added above


    Which of these do you think are causing problems? I haven't bothered the english.php file, and i'm using the overrides folder for the meta_tags.php files.
    I'm thinking that one of them may be something to do with the original define I had in english.php (which is why I mis-named it before) but can't find the tutorial i used to make the changes before you started working with me so couldn't say which one.

  9. #9
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Meta Tag Delima

    Quote Originally Posted by DrByte View Post
    Then go to your /includes/languages/english/ folder and copy meta_tags.php to YOURTEMPLATE/meta_tags.php
    and add these to the file:
    Code:
    define('HOME_PAGE_META_DESCRIPTION', 'My Home Page description metatags');
    define('HOME_PAGE_META_KEYWORDS','My home page keywords here');
    When you edited your language file instead of simply "adding" the HOME_PAGE_META_KEYWORDS, you renamed it.
    Thus, since it's no longer defined, you get the UPPERCASE NAME OF THE CONSTANT instead (caps not intended to appear shouting).


    Quote Originally Posted by GrandmaJ View Post
    The only problem now is that it's putting the phrase "Custom Keywords" at the end of the keywords list as such:

    "dog bowtie, bow tie for dogs, black, red, large, small CUSTOM_KEYWORDS"

    The EXACT line I have in the meta_tags.php in the english folder is:

    define('HOME_PAGE_META_KEYWORDS', 'dog clothes, accessories, dog supplies, collars, dog beds, small dog carriers, travel, pet, puppy');
    If you don't wish to have custom keywords assigned to all pages, simply define it as blank:

    Code:
    define('CUSTOM_KEYWORDS', '');
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Feb 2007
    Posts
    107
    Plugin Contributions
    0

    Default Re: Meta Tag Delima

    Ahh... so I did. I added the line back in as you said and everything works perfectly fine now on all pages.

    I do apologize for causing you the added trouble though... I'm usually much better at following instructions. Thank you for sticking with me and helping me through this.

 

 

Similar Threads

  1. Main store Meta Tag overwriting Individual Item meta tag
    By DPerezjr in forum Basic Configuration
    Replies: 0
    Last Post: 20 Feb 2010, 11:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg