Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Ultimate SEO URLs - by Chemo


Guest

Recommended Posts

  • Replies 1.9k
  • Created
  • Last Reply

Top Posters In This Topic

I had the same problem installing the SEO for articles enhancement - and then I read your post in this thread suggesting to comment out one line of code. Magic - it did work! Did you had any other issues with this? - really want to go live with this.

 

Apart from one error in the code added to seo_cache.php:

# Get the topic path
?#tep_get_parent_topics($c, $record['id']);

Link to comment
Share on other sites

For those of you considering this contribution it works great. I am already being indexed. sometimes on the first page, sometimes not and that is only my fault because I have not properly seo'd my site. thats my next goal. but I can see with proper seo this is a great contribution!

 

I need to retract, my next goal is to get my froogle working with this contribution although some say it worked right out of the box. probably something in my code that I am doing wrong. Any ideas?

 

Thanks

Eizabeth

Link to comment
Share on other sites

Hi Bobby! Thought my website was all set, but turns out that I have in shopping cart-related pages lots of warnings like these:

 

Warning: in_array(): Wrong datatype for second argument in /www/s/susanrm1/htdocs/catalog/includes/boxes/categories.php on line 40

 

Warning: in_array(): Wrong datatype for second argument in /www/s/susanrm1/htdocs/catalog/includes/boxes/categories.php on line 63

 

Warning: in_array(): Wrong datatype for second argument in /www/s/susanrm1/htdocs/catalog/includes/boxes/categories.php on line 72

 

I did add a contribution for category box, and it works well on other pages, but thought I'd copy it here - at least lines 37-74, the offending lines.

 

The contribution I used (and lightly modified) is located at Great categories

 

// display category name
   // $categories_string .= $foo[$counter]['name'];
   if (tep_has_category_subcategories($counter) || $foo[$counter]['level'] == 0) {
       if ( ($id) && (in_array($counter, $id)) ) {
       // display category name
       $categories_string .= '<table class="categ"><tr><td class="categ" nowrap>' . tep_image(DIR_WS_IMAGES . 'categories/bullet.gif', '', '16', '16') . " </td>";
       } else {
       // display category name
       $categories_string .= '<table class="categ"><tr><td class="categ" nowrap>' . " </td>";
       }
   } else {
   $categories_string .= '<table class="categ"><tr><td class="categ" nowrap>  ' .tep_image(DIR_WS_IMAGES . 'categories/arrow_bullet.gif', 'nokta', '9', '9') . "</td>";
   }
   

   $categories_string .= '<td class="categ"><a href="';

   if ($foo[$counter]['parent'] == 0) {
     $cPath_new = 'cPath=' . $counter;
   } else {
     $cPath_new = 'cPath=' . $foo[$counter]['path'];
   }

   $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);
   $categories_string .= '">';

   if ( ($id) && (in_array($counter, $id)) ) {
     $categories_string .= '<b>';
   }

   //category name
   $categories_string .= $foo[$counter]['name'];



   if ( ($id) && (in_array($counter, $id)) ) {
     $categories_string .= '</b>';
   }

 

You can see examples of my error messages at Secure page. Because the error occurs when the pages load from the secure server (a config maybe special to my host), I looked for a hard-coded path, but I couldn't find anything.

 

Any help would be appreciated. If you think I should go to the author of the other contrib, let me know!

 

Susan

Link to comment
Share on other sites

I have upgraded your contrib on my site but i have still problems with customer sessions,all work fine until i click on nonssl link, when i go on from ssl to nonssl, my account information disappear, and when i 'm come back on ssl  i retrieve my information, my cart disappear so, could you say me in which direction to seek I am lost, My Webpage

thanks a lot for your help

 

 

To anyone else who may encounter this problem I found the reason for it. I assumed I just needed the .htaccess in my main directory. This was incorrect I added the .htaccess file to the /test/ directory and changed the path in it to /test/ and now it works great!

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

I hope someone out there has an answer for this, because it's boggling the hell out of me at the moment :) I installed this contribution a while back, and it seemed to work flawlessly... then i tweaked it for my needs so that the urls are a little prettier, at least in my opinion, and i was going to reupload it as a modified contribution, but i couldn't remember where i'd made all the changes :D so anyway, mine rewrites now, instead of like the -c-<name and cpath>, like this:

 

<basename>/category/<category>/<subcategory>/<subcategory>/index.html

 

and i have regexes that return the entire category and subcategory string as cPath, which is then parsed and queried for to construct the real cPath and cPath_array... this works just fine, and has for quite some time, here's the problem...

 

when i originally installed this, it was on an empty storefront, with a few test products just for checking that urls were being constructed and translated properly, now that i have a little over 300 products in the listings, i'm finding some quirks, here they are:

 

i have 1 puzzle and 1 game that i noticed this from, the puzzle is a Baby "Rex" something-something-something, and the quotations are not being stripped when creating the url or the cached name definition (since this was installed w/ the cache class by chemo as well)... the game is called Uncle Milton's something-something, and the apostrophe isn't being stripped either... i tried manually adding those in to the strip function's array to be stripped altogether, but it didn't work (and i suspect that punctuation that obvious was a part of those codes already), so i took them out... i turned on a test mode where i echo'd the entire cache to the page upon refresh and noticed the definition was appearing w/ that punctuation in it, and then added a line into seo_cache to echo this test message:

 

echo "Uncle Milton's Ant Farm Game stripped to ".strip("Uncle Milton's Ant Farm Game")."<br>";

 

and then inside the while loop that creates the definitions i had it echo this:

 

echo $product['products_name']." stripped to ".strip($product['products_name'])."<br>";

 

i reset the cache and refreshed the page...

 

when i refreshed the page, that line i manually typed in (which is cut and pasted from the product's info on the page, and so should be exactly what is being extracted from products_name) stripped perfectly to:

 

Uncle Milton's Ant Farm Game stripped to uncle-miltons-ant-farm-game

 

then further down the page when i saw the definition for it, it had this:

 

Uncle Milton's Ant Farm Game stripped to uncle-milton's-ant-farm-game

 

the majority of links on my site work just fine, but it seems to not be stripping some of them correctly, any ideas? My strip function is the stock one from the contribution, unmodified by me, i even redownloaded it and compared to the original...

 

Richard Lindsey

Edited by Velveeta

Richard Lindsey

Link to comment
Share on other sites

Hi Bobby! Thought my website was all set, but turns out that I have in shopping cart-related pages lots of warnings like these:

I did add a contribution for category box, and it works well on other pages, but thought I'd copy it here - at least lines 37-74, the offending lines.

 

< snip whole bunch of code >

 

You can see examples of my error messages at Secure page. Because the error occurs when the pages load from the secure server (a config maybe special to my host), I looked for a hard-coded path, but I couldn't find anything.

 

Any help would be appreciated. If you think I should go to the author of the other contrib, let me know!

 

Susan

Susan,

 

I checked the site under SSL and did not notice those errors. However, I am familiar as others have reported the same directly after resetting the cache. This can be corrected by suppressing the error generation by prepending an "@" symbol in front of each in_array() comparison.

 

So, everywhere you see the function in_array put an @ symbol in front of it...that wil suppress the error output. It will not affect form, fit, or function of the category menu.

 

...

the majority of links on my site work just fine, but it seems to not be stripping some of them correctly, any ideas? My strip function is the stock one from the contribution, unmodified by me, i even redownloaded it and compared to the original...

 

Richard Lindsey

You are on the right path to debugging the problem...those are the same steps I would take if it were me doing it. Keep plugging along and tell us what you find...sorry to not be any help but can't do much without looking at the code.

 

Do me a favor and post it on my pastebin and let me take a look. If I get time tomorrow I'll breeze through it => Chemo's PHP Code Pastebin.

 

Bobby

Link to comment
Share on other sites

Susan,

 

I checked the site under SSL and did not notice those errors.  However, I am familiar as others have reported the same directly after resetting the cache.  This can be corrected by suppressing the error generation by prepending an "@" symbol in front of each in_array() comparison.

Bobby

 

Beeeeyutiful. It did the trick! Thank you so much.

 

You didn't see the errors using the link I sent you? Surprising. They showed up every time I hit those pages. The SSL server is a different domain name than my regular domain name, so that's why I thought the errors were generated.

 

Richard - I'm interested in your mod of the this contribution! If you do get it working, will you say so on the forum? I like "pretty" URLs too.

 

Susan

Link to comment
Share on other sites

Hey Chemo,

 

 

If I get this to work tonight I am going to drop you 10 bucks!!!!

 

If I get it done in less than 30 mins I may add more!!!!

Link to comment
Share on other sites

when I add the install-cashe.php and try to go to it it just directs to my main page.

 

 

Any reason why this would happen?

 

 

How else can I add this information to the database?

Link to comment
Share on other sites

yeah I had actually found the correct forum for version 2.0 thats where all of my other questions went. I am hung up on the SID being attached to the end of the site now.

Link to comment
Share on other sites

yeah I had actually found the correct forum for version 2.0 thats where all of my other questions went. I am hung up on the SID being attached to the end  of the site now.

 

This may not work for you (i seem to remember reading that it doesn't work for everyone), but it worked fine for me :) to remove the oscSid being appended to the end of the url, and yet retain the session information (i'd originally tried just changing the variable to false in tep_href_link that controlled the sid being appended, but then it wouldn't retain shopping cart entries or anything), find (on approx. line 148 of *catalog*/includes/application_top.php) this code chunk:

 

// set the session cookie parameters

if (function_exists('session_set_cookie_params')) {

session_set_cookie_params(0, $cookie_path, $cookie_domain);

} elseif (function_exists('ini_set')) {

ini_set('session.use_trans_sid', '0');

ini_set('session.cookie_lifetime', '0');

ini_set('session.cookie_path', $cookie_path);

ini_set('session.cookie_domain', $cookie_domain);

}

 

and replace it with this (i'd comment out the original before pasting in the new one, in case it doesn't work for you, you can simply switch it back):

 

// set the session cookie parameters

if (function_exists('session_set_cookie_params')) {

session_set_cookie_params(0, '/', (tep_not_null($current_domain) ? '.' . $current_domain : ''));

ini_set('url_rewriter.tags', '');

} elseif (function_exists('ini_set')) {

ini_set('session.cookie_lifetime', '0');

ini_set('session.cookie_path', '/');

ini_set('session.cookie_domain', (tep_not_null($current_domain) ? '.' . $current_domain : ''));

ini_set('url_rewriter.tags', '');

}

 

that should do it, it's apparently the php.ini file that controls when certain things happen like the sid getting appended, through the use of the url_rewrite.tags, this simply changes that setting :D

 

Richard Lindsey.

Edited by Velveeta

Richard Lindsey

Link to comment
Share on other sites

So far this looks like one of the better contributions I've seen out there with

regard to ease of setup and complete/clear instructions. Well done.

 

I have a question though. Regarding POST vs get , it appears that my "case"

"buy now" is coded as "post", yet you use "get". I wonder, as a request will fetch either post or get based on my limited understanding, will this work out of the box, or will I need to change your "gets" to "posts" in the appropriate places? I would guess that this would be necessary only where there are tests using if statements with post, would that be correct? If I am not being clear please let me know.

 

Here is a sample of the original code:

 

case 'buy_now' :        if (isset($HTTP_POST_VARS['products_id'])) {
  
                               if (tep_has_product_attributes($HTTP_POST_VARS['products_id'])) {
                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_POST_VARS['products_id']));
                               } else {
                                 $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity($HTTP_POST_VARS['products_id'])+1);
                               }
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;

 

 

Here is the recommeded replacement per instructions:

 

case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id'])) {
                              if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
                                tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
                              } else {
                                $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
                              }
                            }
       if ( (defined('SEO_URLS') && SEO_URLS == 'true') && (defined('SEO_URLS_TYPE') && SEO_URLS_TYPE == 'Rewrite') ){
        $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
      $cPath_array = tep_parse_category_path($cPath);
      $cPath = implode('_', $cPath_array);
      tep_redirect(tep_href_link($goto, 'cPath=' . $cPath . '&' . tep_get_all_get_params($parameters)));
       } else {
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
       }
                            break;

 

 

I don't want to break anything as this has been a heavily modified version, so I will wait for your expertise.

 

Thanks....

Link to comment
Share on other sites

So far this looks like one of the better contributions I've seen out there with

regard to ease of setup and complete/clear instructions.  Well done.

 

I have a question though.  Regarding POST vs get , it appears that my "case"

"buy now" is coded as "post", yet you use "get".  I wonder, as a request will fetch either post or get based on my limited understanding, will this work out of the box, or will I need to change your "gets" to "posts" in the appropriate places?  I would guess that this would be necessary only where there are  tests using if statements with post, would that be correct?  If I am not being clear please let me know.

 

Here is a sample of the original code:

 

case 'buy_now' :        if (isset($HTTP_POST_VARS['products_id'])) {
  
                               if (tep_has_product_attributes($HTTP_POST_VARS['products_id'])) {
                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_POST_VARS['products_id']));
                               } else {
                                 $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity($HTTP_POST_VARS['products_id'])+1);
                               }
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;

Here is the recommeded replacement per instructions:

 

case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id'])) {
                              if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
                                tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
                              } else {
                                $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
                              }
                            }
       if ( (defined('SEO_URLS') && SEO_URLS == 'true') && (defined('SEO_URLS_TYPE') && SEO_URLS_TYPE == 'Rewrite') ){
        $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
      $cPath_array = tep_parse_category_path($cPath);
      $cPath = implode('_', $cPath_array);
      tep_redirect(tep_href_link($goto, 'cPath=' . $cPath . '&' . tep_get_all_get_params($parameters)));
       } else {
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
       }
                            break;

I don't want to break anything as this has been a heavily modified version, so I will wait for your expertise.

 

Thanks....

 

Good question, I hadn't even noticed that when I installed it, I guess I was just caught up in the cutting and pasting (plus it was on a vanilla version of OSC so I wasn't too concerned :D)... I know this has worked fine for me, and you're right, if it were passing the variables via $_POST and he were referencing them with $_GET, I don't think it would work, but I know it does work fine for me... it may have something to do w/ the mod_rewrite rules, which pass everything to the code in the form of a $_GET url with all the options in the url, and it may be that I have it wrong also, and that $_GET will reference $_POST variables, perhaps depending on your version of PHP (I know they've locked it down quite a bit in version 5, and I'm pretty positive you can't reference one array by calling the other and hoping it checks both, but perhaps in older versions you could do this, I'm pretty new to the language)... my advice, as I'm sure anyone will tell you, especially if your code is already heavily modified, would be to simply perform a backup of your code and database prior to installation of this snippet...

 

Richard Lindsey.

Richard Lindsey

Link to comment
Share on other sites

Good question, I hadn't even noticed that when I installed it, I guess I was just caught up in the cutting and pasting (plus it was on a vanilla version of OSC so I wasn't too concerned :D)... I know this has worked fine for me, and you're right, if it were passing the variables via $_POST and he were referencing them with $_GET, I don't think it would work, but I know it does work fine for me... it may have something to do w/ the mod_rewrite rules, which pass everything to the code in the form of a $_GET url with all the options in the url, and it may be that I have it wrong also, and that $_GET will reference $_POST variables, perhaps depending on your version of PHP (I know they've locked it down quite a bit in version 5, and I'm pretty positive you can't reference one array by calling the other and hoping it checks both, but perhaps in older versions you could do this, I'm pretty new to the language)... my advice, as I'm sure anyone will tell you, especially if your code is already heavily modified, would be to simply perform a backup of your code and database prior to installation of this snippet...

 

Richard Lindsey.

 

Hi Richard.

 

Do you recall if the code you replaced was the same as mine?

 

Thanks.

 

Art

Link to comment
Share on other sites

Hi Richard.

 

Do you recall if the code you replaced was the same as mine? 

 

Thanks.

 

Art

 

i'm afraid i don't remember if that was the case, but all you'd have to do to find out is go grab a stock version of OSC and check the application_top file, because that's the version i installed it into, a plain old stock OSC MS2.2... but i can tell you that the case statements above that one (update_product, add_product) use HTTP_POST_VARS, and the ones below it (notify, notify_remove, cust_order) use HTTP_GET_VARS... if this looks similar to yours, then it's probably the same version...

 

Richard Lindsey.

Richard Lindsey

Link to comment
Share on other sites

I had the same problem installing the SEO for articles enhancement - and then I read your post in this thread suggesting to comment out one line of code. Magic - it did work! Did you had any other issues with this? - really want to go live with this.

 

 

I've not found any other issues, I've been testing for a week or so and all seems to be working fine.

 

Neil

Link to comment
Share on other sites

i'm afraid i don't remember if that was the case, but all you'd have to do to find out is go grab a stock version of OSC and check the application_top file, because that's the version i installed it into, a plain old stock OSC MS2.2... but i can tell you that the case statements above that one (update_product, add_product) use HTTP_POST_VARS, and the ones below it (notify, notify_remove, cust_order) use HTTP_GET_VARS... if this looks similar to yours, then it's probably the same version...

 

Richard Lindsey.

 

I love this contribution. I have it installed and I love the results (with 1 exception). Great work, Bobby, and thanks for your replies Richard. I appreciate the help. :)

 

Unfortunately, I have encountered a problem with my shopping cart. When trying to add from product listings, it takes me to the cart but nothing gets added. It does work with product info, however. Anyone have any ideas?

 

Thanks in advance for any help you can give me.

 

Art

Link to comment
Share on other sites

Any idea why when I set the ?Enable SEO URL?s? to false, my category links start spinning in an endless redirect loop? Shouldn?t is be include only if ?Enable SEO URL?s? set to ?true??

 

Ari

Link to comment
Share on other sites

Unfortunately, I have encountered a problem with my shopping cart.? When trying to add from product listings, it takes me to the cart but nothing gets added.? It does work with product info, however.? Anyone have any ideas? ... Art

 

I had the same problem and then I remembered that I changed my "add to cart" to form submission rather then href - so whenever you have somthing like this...

 case 'buy_now' : ? ? ? ?if (isset($HTTP_GET_VARS['products_id']))

 

change it to HTTP_POST_VARS

Edited by ari
Link to comment
Share on other sites

I had the same problem and then I remembered that I changed my "add to cart" to form submission rather then href - so whenever you have somthing like this...

 case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id']))

 

change it to HTTP_POST_VARS

 

 

Hi Ari:

 

I had a hunch that might be the ticket. Seems to be working fine now.

 

Thanks....

 

Art

Link to comment
Share on other sites

Hi,

 

Ive searched everywhere and cant solve this.

 

How can i prevent my sorted pages (by product name/price) from being indexed. I realize i cant include special characters in robots.txt, but this is the effect i would want:

Disallow: /*?sort=2d&page=1

Disallow: /*?sort=2a&page=1

Disallow: /*?sort=3a&page=1

Disallow: /*?sort=3d&page=1

 

I need the user to be able to sort the pages internally, so total redirect in htaccess would not work. If i could somehow get all requests from outside the domain to redirect to a move permanently? or perhaps i could change these urls to forms - if i knew how, this would probably be easiest...

 

Suggestions?

Link to comment
Share on other sites

Hi,

 

Ive searched everywhere and cant solve this.

 

How can i prevent my sorted pages (by product name/price) from being indexed. I realize i cant include special characters in robots.txt, but this is the effect i would want:

Disallow: /*?sort=2d&page=1

Disallow: /*?sort=2a&page=1

Disallow: /*?sort=3a&page=1

Disallow: /*?sort=3d&page=1

 

I need the user to be able to sort the pages internally, so total redirect in htaccess would not work. If i could somehow get all requests from outside the domain to redirect to a move permanently? or perhaps i could change these urls to forms - if i knew how, this would probably be easiest...

 

Suggestions?

 

This is a tricky one, because of the way the searchbots work... one way you could do it would be to go into includes/application_top.php (approx. line 200) and find where the spider check is done and if passed, the session is started... at that point i would register $spider_flag... then, anywhere you don't want spiders to index options, such as sort options, check if $spider_flag is registered, and if it's not (most likely a spider) then don't print the href link for those options in the column headers, otherwise print them... that way a user can still sort, and a spider can still see the same page (default-sorted), but the clickable links to sort by various columns won't work for the spider to follow, and it can't index the page w/ those extra options...

 

i don't think you can do it w/ .htaccess, even if you got a mod_rewrite snippet that would convert your arguments into directory appearance (like index.php/sort/2/page/1), because i believe .htaccess operates after mod_rewrite translates the url, so it would still be operating on the actual file (index.php or whatever) and wouldn't be able to deny access for spiders to say, index.php/*

 

Hope that helps...

 

Richard Lindsey.

Richard Lindsey

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...