You are here:  » move "The" back to the beginning of the title and remove ","


move "The" back to the beginning of the title and remove ","

Submitted by stonecold111 on Sun, 2013-08-18 17:16 in

Hi,
suppose there's a product called "The 26th Street". The feed lists it as "26th Street, The", which makes it impossible to compare. How can I move "The" back to the beginning and remove the ","?

Submitted by support on Mon, 2013-08-19 08:44

Hi,

Since this is probably a regular occurrence for certain types of product it's probably worthy of it's own filter. Add the following code to your includes/filter.php:

  /*************************************************/
  /* Title Reorder */
  /*************************************************/
  $filter_names["titleReorder"] = "Title Reorder";
  function filter_titleReorderConfigure($filter_data)
  {
    print "<p>There are no additional configuration parameters for this filter.</p>";
  }
  function filter_titleReorderValidate($filter_data)
  {
  }
  function filter_titleReorderExec($filter_data,$text)
  {
    if (preg_match("/^(.*), The$/",$text))
    {
      $text = "The ".str_replace(", The","",$text);
    }
    return utf8_decode($text);
  }

And then add a new "Title Reorder" filter to the Product Name field and that will re-order for example "26th Street, The" into "The 26th Street" as required.

Cheers,
David.
--
PriceTapestry.com

Submitted by stonecold111 on Mon, 2013-08-19 19:32

You've made my script very powerful now.

Submitted by support on Mon, 2013-08-19 19:45

No worries!

Cheers,
David.
--
PriceTapestry.com