Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Anyway to ignore "The" when products alphabetize?


seanpatrick

Recommended Posts

Posted

I would love to have it so my store displays products in alphabetical order, but also ignore "The" at the beginning without removing or reformatting the title. Is this possible? I assume it's an easy PHP tweak, I'm just not sure where or how.

 

Thanks!

 

EX:

 

CURRENTLY DOES THIS...

 

Blue

Red

The Green

 

WANT TO DO THIS...

 

Blue

The Green

Red

Posted

use

 

[font="Courier New"]$output = preg_replace('/The/', '', $string, 1);[/font]

 

if you need to find how the default sort order is set, read http://www.oscommerce.com/forums/index.php?showtopic=308798&hl=

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Posted

oops, just spotted the forum messed the code, try again!!

 

$output = preg_replace('/The/', '', $string, 1);

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Posted

oops, just spotted the forum messed the code, try again!!

 

$output = preg_replace('/The/', '', $string, 1);

 

Awesome! Thanks for the code... now where do I put/replace that for the product listings on index.php?

Posted

Oops, I made a boo boo! I gave you php code to remove the 'The' but you need sql!!

 

The post I linked details where the default listing is set.

 

The code u will find is: (there are 2 instances, do both)

 

$listing_sql .= " order by pd.products_name";

 

you need to change that to:

 

$listing_sql .= " order by TRIM( LEADING 'The ' FROM pd.products_name)";

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Posted

Oops, I made a boo boo! I gave you php code to remove the 'The' but you need sql!!

 

The post I linked details where the default listing is set.

 

The code u will find is: (there are 2 instances, do both)

 

$listing_sql .= " order by pd.products_name";

 

you need to change that to:

 

$listing_sql .= " order by TRIM( LEADING 'The ' FROM pd.products_name)";

 

Perfect! Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...