About Club osCommerce

Showcasing osCommerce – the good, the bad and the ugly!

StumbleUpon It! DIGG It!

SEO Urls 5 by FWR Media & HT SEO 3 by Jack MCS

Written By Gary on Jun 26 2009 · Comments (6)

Today I had a client who needed HT SEO installed on a site - no real problems as it's a nice contribution that is well maintained by Jack MCS. However this client is running a Template Monster template, which, as we all know, is the epitome of crap coding...

However, the installation was made. To find that it did not work. After some bug-hunting, I was 100% sure that the error lay with the FWR Media's SEO Urls 5. So I turned it off. And HT SEO started working flawlessly. Turn it back on and it stopped working...

So, more investigations...led me to see that HT SEO depends greatly upon this:

PHP:
  1. basename($_SERVER['PHP_SELF'])

to ascertain which page is being shown in the browser and hence which "tags" to load up and show. My thought was that SEO Urls was in some way blocking this from happening, which was causing the tags not to load, particularly on product_info.php.

So, I opened up /includes/header_tags.php and found this piece of code;

PHP:
  1. require_once(DIR_WS_FUNCTIONS . 'clean_html_comments.php'); // Clean out HTML comments from ALT tags etc.

Right below it, I added this:

PHP:
  1. echo basename($_SERVER['PHP_SELF']);

- then I reloaded the page.

With SEO Urls turned OFF, the resulting info was;

product_info.php

And with SEO Urls turned on, the result was something like;

baby-p-145

Now, I absolutely knew that the error was as I thought. I then went hunting and found a similar story on the old "Chemo" version of SEO Urls and so I took that code and inserted it in the header_tags.php file in place of the PRODUCT_INFO case.

And it worked! With SEO Urls turned on. I then emailed Jack MCS to see if this would impact on HT SEO. All well.

Anyway, Jack came up with some nicer code as follows;

1. open up /includes/header_tags.php
2. find EVERY occurence of basename($_SERVER['PHP_SELF']) and replace this with $page
3. add this:

PHP:
  1. $pos = strripos($_SERVER['PHP_SELF'], "/");
  2. $page = ($pos !== FALSE) ? basename(substr($_SERVER['PHP_SELF'], 0, $pos)) : basename($_SERVER['PHP_SELF']);

right before

PHP:
  1. switch (true) {

4. save and upload

SEO Urls 5 and HT SEO now play nicely together.


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive. Cheers!


6 Comments

  1. Hi Gary,

    I tried the solution, but with my site it's not working.

    I get:
    Parse error: parse error in D:\www\goodlivesbeads.nl\www\winkelen2\catalog\includes\header_tags.php on line 37

    Best regards,
    Claudia

    Comment by Claudia — June 30, 2009 @ 10:37 am


  2. Claudia – means you've a mistake at line 37 of the header_tags file

    Comment by Gary — July 1, 2009 @ 12:11 pm


  3. I indeed made a stupid mistake I changed (basename($_SERVER['PHP_SELF']) instead of basename($_SERVER['PHP_SELF']) ( without the '('). So the page is not giving errors anymore, but Header tags is not working with the new code. It is

    By the way I found this line: switch (true) { twice in header_tags.php, did you added the new code before both the lines?

    And the code that you place that after:
    require_once(DIR_WS_FUNCTIONS . 'clean_html_comments.php');
    Do you still have that in your file?

    Maybe it's not working with my site because I'm on a Windows server.

    Comment by Claudia — July 6, 2009 @ 10:14 am


  4. It could be because you are on a windows server – why don't you change to a linux server, your life would be much easier ;)

    Comment by Gary — July 6, 2009 @ 11:06 am


  5. Hi Gary,

    I followed your instructions eg. Jacks instructions and my Header Tags 3.1.5 works fine together with USU5 but only in Rewrite: standard mode. When I toggle USU5 to Rewrite: rewrite mode eg. when urls are .html only default header tag is displayed for all product and category pages. What is solution?

    Comment by misa — July 6, 2009 @ 4:51 pm


  6. [...] don't see anything of the Header tags Seo anymore. There is a solution from Gary and Jack on Clubosc, but that's also not working on my [...]

    Pingback by Install Ultimate SEO Urls 5 on Windows iis 6 « Struggle with OsCommerce — July 10, 2009 @ 3:39 pm


Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!