Jump to content
FWR Media

KissMT Dynamic SEO Meta & Canonical Header Tags

Recommended Posts

I just re-read what I last wrote and I hope it didnt come across in a bad way.

What I meant to say was this is the best I could come up with and if theres a better way Id like to know, and with my limited knowledge Im not yet opened up to what opportunities are available to me.

Share this post


Link to post
Share on other sites

I have a question regarding the product_info.php on KissMT modules dir.

 

I always have this array_flip() error :

 

array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in /home/store/public_html/store/includes/modules/kiss_meta_tags/modules/product_info.php on line 41

 

Line 41 is this:

 

$breadcrumb = array_flip( KissMT::init()->retrieve( 'breadcrumb' ) ); 

 

I figured that it has something to do about breadcrumbs, since my store/product_info.php has no $breadcrumb included in it. Am I right? How should I fix this error? Your reply would be much appreciated. Thanks!

Share this post


Link to post
Share on other sites

I have a question regarding the product_info.php on KissMT modules dir.

 

I always have this array_flip() error :

 

array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in /home/store/public_html/store/includes/modules/kiss_meta_tags/modules/product_info.php on line 41

 

Line 41 is this:

 

$breadcrumb = array_flip( KissMT::init()->retrieve( 'breadcrumb' ) ); 

 

I figured that it has something to do about breadcrumbs, since my store/product_info.php has no $breadcrumb included in it. Am I right? How should I fix this error? Your reply would be much appreciated. Thanks!

 

Breadcrumb should always exists as the class is instantiated and the breadcrumb populated in includes/application_top.php. The code that does this is listed below: -

// include the breadcrumb class and start the breadcrumb trail
 require(DIR_WS_CLASSES . 'breadcrumb.php');
 $breadcrumb = new breadcrumb;

 $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
 $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

// add category names or the manufacturer name to the breadcrumb trail
 if (isset($cPath_array)) {
   for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
     $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
     if (tep_db_num_rows($categories_query) > 0) {
       $categories = tep_db_fetch_array($categories_query);
       $breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
     } else {
       break;
     }
   }
 } elseif (isset($HTTP_GET_VARS['manufacturers_id'])) {
   $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
   if (tep_db_num_rows($manufacturers_query)) {
     $manufacturers = tep_db_fetch_array($manufacturers_query);
     $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));
   }
 }

// add the products model to the breadcrumb trail
 if (isset($HTTP_GET_VARS['products_id'])) {
   $name_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' AND language_id=" . (int)$languages_id . "");
   if (tep_db_num_rows($name_query)) {
     $name = tep_db_fetch_array($name_query);
     $breadcrumb->add($name['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
   }
 }

Edited by FWR Media

Share this post


Link to post
Share on other sites

Breadcrumb should always exists as the class is instantiated and the breadcrumb populated in includes/application_top.php. The code that does this is listed below: -

 

I've checked my application_top.php and that code snippet is listed. I've checked my site again, and it seems that on the products where the array_flip warning exists, they were gone. I've tried uploading a new product and that same error exists. However, when I refresh the page, the array_flip warning is gone.

 

I have USU5 installed. I think it now has something to do with the caching of KissMT. I asked another guy to browse the site and the array_flip warning was visible on his session as well.

Share this post


Link to post
Share on other sites

I've checked my application_top.php and that code snippet is listed. I've checked my site again, and it seems that on the products where the array_flip warning exists, they were gone. I've tried uploading a new product and that same error exists. However, when I refresh the page, the array_flip warning is gone.

 

I have USU5 installed. I think it now has something to do with the caching of KissMT. I asked another guy to browse the site and the array_flip warning was visible on his session as well.

 

My thoughts at this stage is that your site has a problem with the standard osCommerce $breadcrumb not existing in certain circumstances. Nothing has suggested to me a flaw in KissMT that needs finding.

Share this post


Link to post
Share on other sites

Hi, Rob.

 

I have used print_r to print the contents of KissMT::init()->retrieve( 'breadcrumb' ).

 

I've come up with this Array when I click a TShirt for men:

 

Array ( [0] => [1] => Men's Apparel [2] => Apparel )

 

The reason for [0] not having any values must've been because I commented out the following on application_top.php:

 

$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);

 

Is this the right reason, and is it affecting my breadcrumb trail? I've checked and [0] has a null value, causing array_flip to have a warning.

 

 

EDIT: since the array is reversed, I think there's no issue with the above code being commented. I think the main issue here is that I don't get the product name on my breadcrumb (that's suppose to be held on index 0 of the breadcrumb array).

 

I'll look around to see if I can find something. However, your help will be much appreciated. :)

Edited by Winterburn

Share this post


Link to post
Share on other sites

Hi, Rob.

 

I have used print_r to print the contents of KissMT::init()->retrieve( 'breadcrumb' ).

 

I've come up with this Array when I click a TShirt for men:

 

Array ( [0] => [1] => Men's Apparel [2] => Apparel )

 

The reason for [0] not having any values must've been because I commented out the following on application_top.php:

 

$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);

 

Is this the right reason, and is it affecting my breadcrumb trail? I've checked and [0] has a null value, causing array_flip to have a warning.

 

Sort of. $_trail is an empty array until you add something using the add() method, so your code is adding an empty value.

Share this post


Link to post
Share on other sites

Sort of. $_trail is an empty array until you add something using the add() method, so your code is adding an empty value.

 

I've got it. It was something in this code that was not returning any value:

 

add the products model to the breadcrumb trail
if (isset($HTTP_GET_VARS['products_id'])) {
   $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
   if (tep_db_num_rows($model_query)) {
     $model = tep_db_fetch_array($model_query);
     $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
   }
 }

 

The array_flip happens when I don't specify a product model for my products, thus making the final content of the breadcrumb null. I've replaced it with products name instead:

 

// add the products name to the breadcrumb trail
 if (isset($HTTP_GET_VARS['products_id'])) {
$model_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
if (tep_db_num_rows($model_query)) {
  $model = tep_db_fetch_array($model_query);
  $breadcrumb->add($model['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
}
 }

 

and the warning disappeared. However, my breadcrumb looks terrible:

 

Top » Home » Apparel » Men's Apparel » Organic T-Shirt » Organic T-Shirt

 

since the breadcrumb was forcibly added. So I dug deeper and found this on catalog/product_info.php:

 

<?php echo tep_draw_title_top();?>

			<div class="left_part"><?php echo $breadcrumb->trail(' » ')?> »  <?php echo $products_name; ?></div><div class="right_part"><?php echo $products_price2; ?></div>

<?php echo tep_draw_title_bottom();?>

 

I just removed the » <?php echo $products_name; ?> part and the breadcrumb was fixed. Hope this helps for those who are having array_flip problems on KissMT!

Share this post


Link to post
Share on other sites

in the instructions for optional_extras, it states to to change

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

 

TO:

            <td class="pageHeading">
             <h1>
               <?php
                 // KissMT start
                 echo KissMT::init()->page_title . PHP_EOL;
                 // KissMT end
               ?>
             </h1>
           </td>

 

This is what I have for the three of them:

First:

            <td class="pageHeading"><?php echo $breadcrumb->last(' » '); ?></td> 

 

Second:

            <td class="pageHeading"><?php echo $breadcrumb->last(' » '); ?></td>

 

Third:

            <td class="pageHeading" align="right"><?php // echo tep_image(DIR_WS_IMAGES . 'table_background_default.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

 

So what the <?php echo $breadcrumb->last(' » '); ?>

 

Thanks.

Share this post


Link to post
Share on other sites

Have another issue. After doing the the optional_extras, I get a blank page whenever I click admin -> catalog. But once I remove the three changes, then I can access the catalog module. It's an easy install, did try it three times, and all with the same results.

Share this post


Link to post
Share on other sites

my title use Men's Health , I have edit the languages it didn't work, if I remove the ' to Men Health the title was show, can help for this? I like my Title with ' and %, how it work

Share this post


Link to post
Share on other sites

my title use Men's Health , I have edit the languages it didn't work, if I remove the ' to Men Health the title was show, can help for this? I like my Title with ' and %, how it work

 

This is standard PHP stuff. If the delimiter is a single colon you have to escape single colons .. if the delimiter is a double colon you have to escape double colons .. like ..

 

  define( 'TEXT', 'I am text with a \' single colon' );

 define( "TEXT", "I am text with a \" double colon" );

Share this post


Link to post
Share on other sites

This is standard PHP stuff. If the delimiter is a single colon you have to escape single colons .. if the delimiter is a double colon you have to escape double colons .. like ..

 

  define( 'TEXT', 'I am text with a \' single colon' );

 define( "TEXT", "I am text with a \" double colon" );

define( 'KISSMT_HOMEPAGE_TITLE', 'Men \' s Health' );

 

it show Men S Health

Share this post


Link to post
Share on other sites

define( 'KISSMT_HOMEPAGE_TITLE', 'Men \' s Health' );

 

it show Men S Health

 

I see what you mean. Yes non a-zA-Z0-9 characters are removed by design and replaced with a space.

Share this post


Link to post
Share on other sites

I see what you mean. Yes non a-zA-Z0-9 characters are removed by design and replaced with a space.

so can edit the files? show non a-zA-Z0-9 characters?

Share this post


Link to post
Share on other sites

so can edit the files? show non a-zA-Z0-9 characters?

I did it

 

private function stripCharacters( $string, $type = 'description' ) {

$no_tags = preg_replace( '@<[\/\!]*?[^<>]*?>@si', ' ', $this->stripSymbols( $string ) );

switch( $type ) {

case 'keywords':

$pattern = "@[!#\$%&\"()\*\+,\./:;<=>\?\@\[\]\^_`\{|\}~\n\r\t]+@";

break;

case 'title':

$pattern = "@[!#\$%\"()\*\+,\./:;<=>\?\@\[\]\^_`\{|\}~\n\r\t]+@";

break;

default:

$pattern = "@[!#\$%\"()\*\+/:;<=>\?\@\[\]\^_`\{|\}~\n\r\t]+@";

break;

}

$no_special_characters = preg_replace( $pattern, ' ', $no_tags );

$no_special_characters = str_replace( "'", '', $no_special_characters );

return $remove_multi_spaces = preg_replace( '@[\s]{2,100}@', ' ', $no_special_characters );

}

 

private function buildPageTitle( $leading_values ) {

if ( substr( $leading_values, -13, 13 ) == '[-separator-]' ) {

$leading_values = substr( $leading_values, 0, strlen( $leading_values ) -13 );

}

KissMT::init()->page_title = $this->trimWordsToLength( str_replace( '[-separator-]', ' ' . KissMT::init()->retrieve( 'title_separator' ) . ' ', $leading_values ), 'page_title' );

}

 

replace

 

private function stripCharacters( $string, $type = 'description' ) {

$no_tags = preg_replace( '@<[\/\!]*?[^<>]*?>@si', ' ', $this->stripSymbols( $string ) );

switch( $type ) {

case 'keywords':

$pattern = "@[!]+@";

break;

case 'title':

$pattern = "@[!]+@";

break;

default:

$pattern = "@[!]+@";

break;

}

$no_special_characters = preg_replace( $pattern, ' ', $no_tags );

$no_special_characters = str_replace( "", '', $no_special_characters );

return $remove_multi_spaces = preg_replace( '@[\s]{2,100}@', ' ', $no_special_characters );

}

 

private function buildPageTitle( $leading_values ) {

if ( substr( $leading_values, -13, 13 ) == '[-separator-]' ) {

$leading_values = substr( $leading_values, 0, strlen( $leading_values ) -13 );

}

KissMT::init()->page_title = $this->trimWordsToLength( str_replace( '[-separator-]', ' ' . KissMT::init()->retrieve( 'title_separator' ) . ' ', $leading_values ), 'page_title' );

}

Share this post


Link to post
Share on other sites

I did it

 

private function stripCharacters( $string, $type = 'description' ) {

$no_tags = preg_replace( '@<[\/\!]*?[^<>]*?>@si', ' ', $this->stripSymbols( $string ) );

switch( $type ) {

case 'keywords':

$pattern = "@[!#\$%&\"()\*\+,\./:;<=>\?\@\[\]\^_`\{|\}~\n\r\t]+@";

break;

case 'title':

$pattern = "@[!#\$%\"()\*\+,\./:;<=>\?\@\[\]\^_`\{|\}~\n\r\t]+@";

break;

default:

$pattern = "@[!#\$%\"()\*\+/:;<=>\?\@\[\]\^_`\{|\}~\n\r\t]+@";

break;

}

$no_special_characters = preg_replace( $pattern, ' ', $no_tags );

$no_special_characters = str_replace( "'", '', $no_special_characters );

return $remove_multi_spaces = preg_replace( '@[\s]{2,100}@', ' ', $no_special_characters );

}

 

private function buildPageTitle( $leading_values ) {

if ( substr( $leading_values, -13, 13 ) == '[-separator-]' ) {

$leading_values = substr( $leading_values, 0, strlen( $leading_values ) -13 );

}

KissMT::init()->page_title = $this->trimWordsToLength( str_replace( '[-separator-]', ' ' . KissMT::init()->retrieve( 'title_separator' ) . ' ', $leading_values ), 'page_title' );

}

 

replace

 

private function stripCharacters( $string, $type = 'description' ) {

$no_tags = preg_replace( '@<[\/\!]*?[^<>]*?>@si', ' ', $this->stripSymbols( $string ) );

switch( $type ) {

case 'keywords':

$pattern = "@[!]+@";

break;

case 'title':

$pattern = "@[!]+@";

break;

default:

$pattern = "@[!]+@";

break;

}

$no_special_characters = preg_replace( $pattern, ' ', $no_tags );

$no_special_characters = str_replace( "", '', $no_special_characters );

return $remove_multi_spaces = preg_replace( '@[\s]{2,100}@', ' ', $no_special_characters );

}

 

private function buildPageTitle( $leading_values ) {

if ( substr( $leading_values, -13, 13 ) == '[-separator-]' ) {

$leading_values = substr( $leading_values, 0, strlen( $leading_values ) -13 );

}

KissMT::init()->page_title = $this->trimWordsToLength( str_replace( '[-separator-]', ' ' . KissMT::init()->retrieve( 'title_separator' ) . ' ', $leading_values ), 'page_title' );

}

 

I'm afraid that what you have done there is destroy the replace patterns.

Share this post


Link to post
Share on other sites

I did it

 

This will probably work for you.

 

    /**
   * Strip out unwanted characters, spaces etc.
   * 
   * @param mixed $string - string to be stripped
   * @param mixed $type - title/keywords/description may need a different strip pattern
   * @return string - formatted/stripped string
   */
   private function stripCharacters( $string, $type = 'description' ) {
     $no_tags = preg_replace( '@<[\/\!]*?[^<>]*?>@si', ' ', $this->stripSymbols( $string ) );
     switch( $type ) {
       case 'keywords':
         $pattern = "@[!#\$%&\"()\*\+,\./:;<=>\?\@\[\]\^_`\{|\}~\n\r\t]+@";
         $no_tags = str_replace( "'", '', $no_tags );
         break;
       case 'title':
         $pattern = "@[!#\$%\"()\*\+,\./:;<=>\?\@\[\]\^_`\{|\}~\n\r\t]+@";
         break;
       default:
         $pattern = "@[!#\$%\"()\*\+/:;<=>\?\@\[\]\^_`\{|\}~\n\r\t]+@";
         $no_tags = str_replace( "'", '', $no_tags );
         break;
     }
     $no_special_characters = preg_replace( $pattern, ' ', $no_tags );
     return $remove_multi_spaces = preg_replace( '@[\s]{2,100}@', ' ', $no_special_characters );
   }

Share this post


Link to post
Share on other sites

Important Notice:

 

As standard KissMT currently sets the canonical link of the root page as www.mysite.com/index.php.

 

The reason for this is that there is internal linking to this ( breadcrumb etc. ) whereas there is no internal linking to the version without index.php.

 

It has been brought to my attention that users may wish their root page to be www.mysite.com/ ( without the index.php ) and further investigation following helpful information by squid ( a forum member ) suggests that the version without the index.php could be a better standard option.

 

This will be addressed in the new revision but for current users wishing to have this now .. the code change is below: -

 

open catalog/includes/modules/kiss_meta_tags/abstracts/kiss_modules.php

 

Find ..

 

 

    private function forceHttp( $the_current_canonical_link ) {

 

 

change to ..

 

 

    private function forceHttp( $the_current_canonical_link ) {
     // mod suggested by squid - thanks
     if ( substr( $the_current_canonical_link, -strlen( FILENAME_DEFAULT ), strlen( $the_current_canonical_link ) ) == FILENAME_DEFAULT ) {
       $the_current_canonical_link = substr( $the_current_canonical_link, 0, strlen( $the_current_canonical_link )-strlen( FILENAME_DEFAULT ) );
     }

 

Another point correctly brought to my attention by squid is that if you currently have code in place in .htaccess to redirect www.mysite.com/index.php to www.mysite.com/ this should now be removed as the canonical element will do the same job.

Share this post


Link to post
Share on other sites

Hi, I too am having trouble getting the root page to be www.mysite.com/ ( without the index.php ) so I thought I would try this suggestion and when I look at the file you say to change

open catalog/includes/modules/kiss_meta_tags/abstracts/kiss_modules.php - I do not have those lines in it. I have looked in the update files and they look the same to me as the old ones.

Nowhere can I find this statement:

private function forceHttp( $the_current_canonical_link ) {

 

I have my store in the root and have installed everything except the admin stuff, (Still getting used to everything) and the H1 page titles (since my descriptions came from old html of another source and I don't want to go there yet)

So after everything else I stopped and let google do his thing. I am still trying to figure out where to go next but from what I can see so far this is doing a great job of getting the content to google so far. Let me know if I can give you my link to check. If I can get this answer, I have a few more. Thanks

Share this post


Link to post
Share on other sites

I added KissMT to my site, which i'm very happy with. On the products pages I notice the Title has the product name and catagory and subcatagory. Is there a way to set it up to just have the product name in the title? Also Is there a way to remove title and category out of the description? The description has the title ,catagory,Sub-catagory plus the description which already has the product name in it.

Share this post


Link to post
Share on other sites

I added KissMT to my site, which i'm very happy with. On the products pages I notice the Title has the product name and catagory and subcatagory. Is there a way to set it up to just have the product name in the title? Also Is there a way to remove title and category out of the description? The description has the title ,catagory,Sub-catagory plus the description which already has the product name in it.

 

Try the following: -

 

includes/modules/kiss_meta_tags/modules/product_info.php

 

Find ...

 

 

      $breadcrumb = array_flip( KissMT::init()->retrieve( 'breadcrumb' ) ); 
     if ( array_key_exists( $product_results['products_model'], $breadcrumb ) ) {
       unset( $breadcrumb[$product_results['products_model']] );
     }
     if ( array_key_exists( $product_results['products_name'], $breadcrumb ) ) {
       unset( $breadcrumb[$product_results['products_name']] );
     }
     $breadcrumb = array_flip( $breadcrumb );
     $leading_values = KissMT::init()->entities( trim( $product_results['products_name'] ), $decode = true );
     if ( tep_not_null( $product_results['products_model'] ) ) {  
        $leading_values .= '[-separator-]' . trim( $product_results['products_model'] );
     } 
     $leading_values .= '[-separator-]' . implode( '[-separator-]', $breadcrumb );
     if ( tep_not_null( $product_results['manufacturers_name'] ) ) { 
       $leading_values .= '[-separator-]' . sprintf( KISSMT_BRAND_TEXT, trim( $product_results['manufacturers_name'] ) );
     }

 

Replace with just ..

 

     $leading_values = KissMT::init()->entities( trim( $product_results['products_name'] ), $decode = true );

 

That should do it. ( don't forget to reset the cache ).

Share this post


Link to post
Share on other sites

When I click on a Catagory ,I notice in the title is the name of a product that is not on that page. Each catagory has more than one page of products and it picks the product from the last page. But is there a way to have it pick a product from the first page to be in the title?

Share this post


Link to post
Share on other sites

When I click on a Catagory ,I notice in the title is the name of a product that is not on that page. Each catagory has more than one page of products and it picks the product from the last page. But is there a way to have it pick a product from the first page to be in the title?

 

You would need to add an ORDER BY statement to the query ..

 

$this->cPath_products_query in modules/index.php

Share this post


Link to post
Share on other sites

You would need to add an ORDER BY statement to the query ..

 

$this->cPath_products_query in modules/index.php

 

Wat is an Orderby statement and

How do I do that?

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

×