You are here:  » External Drupal


External Drupal

Submitted by affiliben on Sat, 2010-10-02 10:58 in

Hi David,
Thanks for sending the external.php over. After some consideration I decided it wasn't for me due to the complexity of the urls and other factors and I have since discovered another way to integrate Price Tapestry with Drupal, which I will share as there might be other looking for the same solution. This should only be tried by someone who is used to drupal and fairly confident with the modules.
You will have to create an extra field in your PT table for product url.
Once that is done this is how you do it. if you use drupal 6, add the CCK, Views, Viewfield Schema Table wizard modules. In your Drupal settings.php you can add another database (and as they are both mysql it is no problem), so add your PT database name. Then when you use the Table Wizard it finds the tables of your database which you can select the products table.
You can then build a view from the PT products table using arguments to choose the category. You can then create a new content type with one field being the view field which you can then use the different argument with the same view for each node. One thing that is a bit of a pain is theming the view to make it look right, which you need to follow their instructions and example very carefully to get your head around it.
As I said this is not for the faint hearted as the drupal site is known for being written by programmers for programmers and I have only done this as it made more sense for me.
This has brought up one small issue that I would like a help on.
I have created a field for the pt properties url, (which is necessary to use the above method) in my table and in my normal pt situation I have used the http://www.pricetapestry.com/node/3239 advice on keeping it all lower case, which is the best strategy in my opinion. I have used filters to compile the url in the pt properties table, i.e text before like mydomain/directory, text after .html, which works, but what I need is a new filter to create the lower case and remove inappropriate characters and put dashes between letters of the product names as my data has apostrophes etc in the name which need to be removed from a possible url.
I have gone into includes/filter.php and copied the name case filters and renamed it lowercase, which I can now see in my pt admin panel, but I need the php (I'm not a php coder) to make this a new filter . I'm sure it will be something like $config_baseHREF."merchant/".tapestry_hyphenate($row["merchant"])."/";
I would be grateful if you could give me the code to duplicate the url lower case for a new filter.
Thanks
Ben

Submitted by support on Sat, 2010-10-02 11:23

Hi Ben,

Sure - use the following code to add a Lower Case filter to your includes/filter.php (insert just before the closing PHP tag at the end of the file):

  /*************************************************/
  /* lowerCase */
  /*************************************************/
  $filter_names["lowerCase"] = "Lower Case";
  function filter_lowerCaseConfigure($filter_data)
  {
    print "<p>There are no additional configuration parameters for this filter.</p>";
  }
  function filter_lowerCaseValidate($filter_data)
  {
  }
  function filter_lowerCaseExec($filter_data,$text)
  {
    return strtolower($text);
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by affiliben on Sat, 2010-10-02 16:23

Hi David
Thanks for the quick response and the code.
That works well in making the text lower case, but it still does not quite match the normal url making process where apostrophes etc are removed and two words are hyphenated . eg. Wrangler's Jeans are now wrangler's jeans, but not wranglers-jeans, which is how they appear in the price tapestry url. Would that be possible to do in a filter?
Thanks
Ben

Submitted by support on Sat, 2010-10-02 16:34

Hi Ben,

You could encapsulate Price Tapestry's normalise and hyphenate functions into a filter - use it in conjunction with Lower Case (sequence won't matter) if you want all lower case URLs:

  /*************************************************/
  /* normalise */
  /*************************************************/
  $filter_names["normalise"] = "Normalise";
  function filter_normaliseConfigure($filter_data)
  {
    print "<p>There are no additional configuration parameters for this filter.</p>";
  }
  function filter_normaliseValidate($filter_data)
  {
  }
  function filter_normaliseExec($filter_data,$text)
  {
    return tapestry_hyphenate(tapestry_normalise($text));
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by affiliben on Sat, 2010-10-02 16:53

Brilliant
Thanks for the quick response.
All the best
Ben