Jump to content
Jack_mcs

Header Tags SEO

Recommended Posts

Replace the file mentioned previously with the following. It should conform to their changed rules. But it is only for one price/language. If multiple prices are present, the code would have to be altered further for that.

<?php

$loc = explode(',',$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
$ogArray = array();                  
$ogArray['site_name'] = STORE_NAME; 
$ogArray['locale']  = str_replace('-', '_', $loc[0]);
$showOG = false;
$showProduct = false;
$showTwitter = false;

$twitterArray = array(); 
$db_query = tep_db_query("select groupname as storename, data as creator from headertags_social where section = 'twitter'");
$db = array();
if (tep_db_num_rows($db_query)) {
    $db = tep_db_fetch_array($db_query);
    $twitterArray[] = '<meta name="twitter:card" content="summary">';
    $twitterArray[] = '<meta name="twitter:site" content="@' . $db['storename'] . '">';
    $showTwitter = true;
}

switch (true) {
    case (basename($_SERVER['SCRIPT_FILENAME']) === 'index.php'):
        if ($category_depth == 'top') {
            $img = (file_exists('store_logo.png') ? tep_href_link('images/store_logo.png', '', $request_type, false, false) : '');
            
            if (! tep_not_null($canonical_url)) {
              $canonical_url = GetCanonicalURL();
            }

            $twitterArray[] = '<meta name="twitter:creator" content="@' . $db['creator'] . '">';
            $twitterArray[] = '<meta name="twitter:url" content="' . tep_href_link('index.php', '', $request_type, false) . '">';
            $twitterArray[] = '<meta name="twitter:title" content="' . $header_tags_array['title'] . '">';
            $twitterArray[] = '<meta name="twitter:description" content="' . $header_tags_array['desc'] . '">';
            $twitterArray[] = '<meta name="twitter:image" content="' . $img . '">';        
            
            $ogArray['type'] = 'website';
            $ogArray['image'] = $img;
            $ogArray['url'] = $canonical_url;
            $showOG = true;
        } 
    break;
    
    case (basename($_SERVER['SCRIPT_FILENAME']) === 'product_info.php'):
    case (basename($_SERVER['SCRIPT_FILENAME']) === 'product_reviews.php'):
    case (basename($_SERVER['SCRIPT_FILENAME']) === 'product_reviews_info.php'):        
        if ($_GET['products_id'] > 0) {
            $og_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_quantity, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_available from products p, products_description pd 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)$languages_id . "'");
        
            if ( tep_db_num_rows($og_query) > 0 ) {
                $og = tep_db_fetch_array($og_query);
                
                $img = (tep_not_null($og['products_image']) ? tep_href_link('images/' . $og['products_image'], '', $request_type, false, false) : '');                
                $url = tep_href_link('product_info.php', 'products_id=' . $og['products_id'], $request_type, false);

                /**** Get the price ****/
                if (($new_price = tep_get_products_special_price($og['products_id']))) {
                } else {
                    $new_price = $og['products_price'];
                }  
                $og_price = $currencies->display_price($new_price, tep_get_tax_rate($og['products_tax_class_id']));
                $og_price = substr($og_price, 1);
                
                $twitterArray[] = '<meta name="twitter:creator" content="@' . $db['creator'] . '">';
                $twitterArray[] = '<meta name="twitter:url" content="' . $url . '">';
                $twitterArray[] = '<meta name="twitter:title" content="' . htmlspecialchars($og['products_name'], ENT_QUOTES) . '">';
                $twitterArray[] = '<meta name="twitter:description" content="' . GetOGDescription($og['products_description']) . '">';
                $twitterArray[] = '<meta name="twitter:image" content="' . $img . '">';  

                $twitterArray[] = '<meta name="twitter:data1" content="' . $og_price . '">';  
                $twitterArray[] = '<meta name="twitter:label1" content="' . HTS_OG_PRICE . '">';  
                
                $twitterArray[] = '<meta name="twitter:data2" content="' . $og['products_quantity'] . '">';  
                $twitterArray[] = '<meta name="twitter:label2" content="' . HTS_OG_AVAILABLE_STOCK . '">';             
            
                $ogArray['type'] = 'product';
                $ogArray['title'] = htmlspecialchars($og['products_name'], ENT_QUOTES);
                $ogArray['description'] = GetOGDescription($og['products_description']);
                $ogArray['image'] = $img;
                $ogArray['url'] = $url;
                $ogArray['product:price:amount'] = $og_price;   
                $ogArray['product:price:currency'] = $currency;
                $ogArray['availability'] = ($og['products_date_available'] > date('Y-m-d H:i:s') ? 'pending' :
                                            $og['products_quantity'] < 1 ? 'oos' :
                                            $og['products_quantity'] > 0 ? 'instock' : 'oos');
                $showOG = true;  
                $showProduct = true;                
            }
        }
    break;

    case (defined('article_info.php') && basename($_SERVER['SCRIPT_FILENAME']) === 'article_info.php'):
        if ($_GET['articles_id'] > 0) {
            $og_query = tep_db_query("select a.articles_date_added, a.articles_last_modified, ad.articles_image, ad.articles_name, a.authors_id, ad.articles_description, ad.articles_url, au.authors_name, td.topics_name from 
              articles a left join 
              authors au on a.authors_id = au.authors_id left join 
              articles_description ad on a.articles_id = ad.articles_id left join 
              articles_to_topics a2t on a.articles_id = a2t.articles_id left join 
              topics_description td on a2t.topics_id = td.topics_id
              where a.articles_status = '1' and a.articles_id = '" . (int)$_GET['articles_id'] . "' and ad.language_id = '" . (int)$languages_id . "'");
            if ( tep_db_num_rows($og_query) > 0 ) {
                $og = tep_db_fetch_array($og_query);
 
                $img = (tep_not_null($og['articles_image']) ? tep_href_link('images/' . $og['articles_image'], '', $request_type, false, false) : '');
                $url = tep_href_link('article_info.php', 'article_id=' . $og['articles_id'], $request_type, false);
                
                $twitterArray[] = '<meta name="twitter:creator" content="@' . (tep_not_null($og['authors_name']) ? $og['authors_name'] : $db['creator']) . '">';
                $twitterArray[] = '<meta name="twitter:url" content="' . $url . '">';
                $twitterArray[] = '<meta name="twitter:title" content="' . htmlspecialchars($og['articles_name'], ENT_QUOTES) . '">';
                $twitterArray[] = '<meta name="twitter:description" content="' . GetOGDescription($og['articles_description']) . '">';
                $twitterArray[] = '<meta name="twitter:image" content="' . $img . '">';  
                
                $ogArray['type'] = 'article';
                $ogArray['url'] = $url;
                $ogArray['description'] = GetOGDescription($og['articles_description']);
                $ogArray['tag'] = $header_tags_array['keywords'];
                if (isset($og['articles_date_added'][1])) $ogArray['published_time'] = $og['articles_date_added'];
                if (isset($og['articles_last_modified'][1])) $ogArray['modified_time'] = $og['articles_last_modified'];
                if (isset($og['expiration_time'][1])) $ogArray['expiration_time'] = $og['expiration_time'];
                if (isset($og['authors_name'][1])) $ogArray['author'] = $og['authors_name'];
                if (isset($og['authors_id'][1])) $ogArray['author'] = tep_href_link('articles.php', 'authors_id=' . $og['authors_id'], $request_type, false);
                if (isset($og['topics_name'][1])) $ogArray['section'] = $og['topics_name'];
                if (isset($og['articles_image'][1])) $ogArray['image'] = $img;
 
                $showOG = true; 
            }    
        }
    break;
}  

if ($showTwitter) { 
    foreach ($twitterArray as $tag => $data) {
        echo $data . "\n";
    }    
}
 
if ($showOG) { 
    foreach ($ogArray as $tag => $data) {
        if ($showProduct && strpos($tag, 'product:price:') !== FALSE) {
            echo '<meta property="' . $tag . '" content="' . $data . '" />' . "\n";
        } else {
            echo '<meta property="og:' . $tag . '" content="' . $data . '" />' . "\n";
        }
    }    
}
 

 

Share this post


Link to post
Share on other sites

Thanks for mentioning it.  I don't keep up on the social sites so there may be others that have gone away too.

Share this post


Link to post
Share on other sites

Hi,

When i do a test i get some duplicates, fixed that and i get this from site :

Title and Meta Tag results for index.php  explain
 
 Nederlands
 
  From Site:
    Title ->
    Meta Description ->
    Meta Keywords ->
 
  From Settings:
    Title -> Foto - Meinema - Online - Fotozaak - Specialist - Fotostudio - Fotografie - Fotograaf
    Meta Description -> Foto Meinema is uw online specialist in alles voor de fotostudio en outdoor
    Meta Keywords -> Foto Meinema, Outdoor, Fotografie, Studio, Optiek, Verrekijker, Accessoires, Falcon Eyes, Telescoop, Spotting Scope, Camera Lensen, Fotostudio, Fotograaf
 
  Results of scan:

    index.php is missing Header Tags code or it is not installed correctly. Verify that Fill Tags has been ran and that the root checkbox or the default checkboxes have been checked in Page Control.

The code is installed in template_top and in index.php on the front side of the shop. What are the best settings for the index.php in page control.

Greetings, Anne

Share this post


Link to post
Share on other sites

Is this a language issue? That is, is there more than one language installed and only this one is not working? What version is your shop? Have you looked at the screenshots in the package? They explain some of the settings. Checking the root box for the index page will add that text to the categories and manufacturers. For some sites this is a good thing. For others it isn't. It depends on what the text is and how relevant it is to those other pages.

Share this post


Link to post
Share on other sites

It might be that the language isn't being detected. In the test routine, are there any errors dealing with the language? Is there a button there to fix or add it?

Share this post


Link to post
Share on other sites

Hi,

Nope, no error of languages.

But i know see that i also get a error on entering a categorie - 1054 - Unknown column 'cd.categories_description' in 'field list'

Reverted back to old backup of database but that didn't work.

Greetings, Anne

 

Share this post


Link to post
Share on other sites

Forgot to mention,

At the database update i got 1060 - Duplicate column name 'ip_number'

ALTER TABLE `headertags_keywords` ADD `ip_number` INT( 64 ) UNSIGNED NOT NULL DEFAULT 0 AFTER found

Think that that is no problem.

Greetings, Anne

Share this post


Link to post
Share on other sites

Hi,

Think i fixed the 1054 error, 

Used the part in index for 3.3.4 in stead of 3.3.5 of the contribution, In 3.3.4 the  if (isset($HTTP_GET_VARS['manufacturers_id'])) { is used and in 3.3.5 is used  if (isset($_GET['manufacturers_id']

The $_Get is the problem.

But how to use the part of 3.3.5 with the HTTP_GET_VARS or can just copie past the HTTP over the $_GET

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

Back to meta error, this is the full text.

  languages in the Header Tags table are: 4 ( Nederlands ).
 
Title and Meta Tag results for index.php  explain
 
 Nederlands
 
  From Site:
    Title ->
    Meta Description ->
    Meta Keywords ->
 
  From Settings:
    Title -> Foto - Meinema - Online - Fotozaak - Specialist - Fotostudio - Fotografie - Fotograaf
    Meta Description -> Foto Meinema is uw online specialist in alles voor de fotostudio en outdoor
    Meta Keywords -> Foto Meinema, Outdoor, Fotografie, Studio, Optiek, Verrekijker, Accessoires, Falcon Eyes, Telescoop, Spotting Scope, Camera Lensen, Fotostudio, Fotograaf
 
  Results of scan:

    index.php is missing Header Tags code or it is not installed correctly. Verify that Fill Tags has been ran and that the root checkbox or the default checkboxes have been checked in Page Control.

 

Greetings, Anne

 

Edited by DjViper
Update of other error

Share this post


Link to post
Share on other sites

For the $_GET problem, you should be able to change all of those instances to $HTTP_GET_VARS, though they are not as secure.

For the test error, when that error is displayed it should show a link to the product that is failing. Click on that and check the product to make sure it has the name, header tags title and meta descriptions entered.

Share this post


Link to post
Share on other sites

The test routine uses $_POST so this may be due to the same problem you mentioned previously. Try doing a search/replace in the admin/header_tags_test.php file, replace all instances of $_POST with $HTTP_POST_VARS.

Share this post


Link to post
Share on other sites

Hi, 

Have tried it. Still the same. 

This is the first part of template_top

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2012 osCommerce

  Released under the GNU General Public License
*/

  $oscTemplate->buildBlocks();

  if (!$oscTemplate->hasBlocks('boxes_column_left')) {
    $oscTemplate->setGridContentWidth($oscTemplate->getGridContentWidth() + $oscTemplate->getGridColumnWidth());
  }

  if (!$oscTemplate->hasBlocks('boxes_column_right')) {
    $oscTemplate->setGridContentWidth($oscTemplate->getGridContentWidth() + $oscTemplate->getGridColumnWidth());
  }
?>
<!DOCTYPE html>
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta charset="<?php echo CHARSET; ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="ROBOTS" CONTENT="INDEX, FOLLOW">
<?php
/*** Begin Header Tags SEO ***/
if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
  require(DIR_WS_INCLUDES . 'header_tags.php');
} else {
?>
  <title><?php echo tep_output_string_protected($oscTemplate->getTitle()); ?></title>
<?php
}
/*** End Header Tags SEO by oscommerce-solution.com ***/

 

Greetings, Anne

Share this post


Link to post
Share on other sites

You can try turning on the ByPass New Pages Check setting. The code may not be able to figure out your version of oscommerce. But I think the problem is with the language. Did you fill in Page Control for all languages? Does it show all languages for that matter. Did you make the file changes and upload the files for all languages?

Share this post


Link to post
Share on other sites

Hi,

Bypass gives nothing, language i also think is the problem. page contrall all filled, and the file changes only to dutch, english is still there in the map but is deleted inside oscommerce setup.

Greetings, Anne

Share this post


Link to post
Share on other sites

Hi,

Is it hard to go back to 3.3.4 - have the 3.3.4. edited files still.

Putting the 3.3.4 edited files back and the headertags files of package 3.3.4.

Database change was only the additional words part i believe and a few extra when i compare.

Greetings, Anne

 

Edited by DjViper

Share this post


Link to post
Share on other sites

There aren't instructions for going backwards but as long as you remove any code that uses the new options, like additional words, then it will work. It doesn't matter about the database, only the files.

But regarding the language, I don't understand this statement: "english is still there in the map but is deleted inside oscommerce setup". To use a language in oscommerce, there needs to be a database entry for it in the localization section and the files for it. If the files are present the code will try to use them, even if a database entry doesn't exist. So you should delete both if you don't use them or make sure they are both present if you do.

You can also try editing the ID of the Dutch language via the database. Set it to 1 and see if that fixes it. Make a note of the original ID in case you need to switch it back. You shouldn't have to unless you have code that loads the language by a hard-coded number.

Share this post


Link to post
Share on other sites

Hi,

Tried the option of lang change to 1, got a little bit further but all products were gone. Will go back to 3.3.4. Still the meta is than not good, but will see if there is a workaround, maybe putting it hardcoded into template_top.

Greetings, Anne

 

Share this post


Link to post
Share on other sites

Hi,

That's true.

I tested a other page links.php and gives the same problem

 From Site:
    Title ->
    Meta Description ->
    Meta Keywords ->
 
  From Settings:
    Title -> Links - Pagina - Link - Partners - Aanbiedingen
    Meta Description -> Links Pagina, Link Partners

    Meta Keywords -> Links Pagina, Link Partners, Partners, Foto Meinema, Link, Links

If i change the language ID in database - language entry to 1 than is From Site and From Setting both empty and red. But also the categories box on main page site is empty.

That also could be that i only changed the entry of languages and not all languages_id entry's in the database. Is there a simple database alter function for.

Edited by DjViper

Share this post


Link to post
Share on other sites

There's is only one table that is the source of the language ID. But when things are saved, they are saved with the ID at that time so if you change the main language ID, entries will be wrong. Instead, look at the headertags table and make sure the language id column for each of the pages is correct for the Dutch language. Also, and maybe try this first, be sure you ran Fill Tags with the languages option set to all. If you did, try switching the language in admin to use Dutch and then run Fill Tags. Fill Tags should get the correct number but maybe something is confusing it.

Share this post


Link to post
Share on other sites

Hi,

Did a fill tags, - Descripton override yes - Keyword override yes

Selected netherlands - Fill all tags all 3 

Got a : (14000 products in database)

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Greetings, Anne

 

Share this post


Link to post
Share on other sites

The test can't see the meta tags when the site is ran in ssl mode. I posted a change for this in the last page or two.

I don't suggest using the overrides when you are trying to solve a problem like this. Just use the section at the very bottom of fill tags.

You're getting the 500 error, most likely, because the script is timing out before it completes due to the number of products involved and the servers timeout setting. But fill tags doesn't affect the home page so I would concentrate on that problem.

I'm confused at this point as to what the problem is. The source of your home page shows the title and tags so Header Tags appears to be working. What is the problem?

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×