Support forum login

©2006-2010 IAAI Software

Contact Us

Showing search and price comparison tables on other sites

Submitted by support on Tue, 2008-09-16 16:12.

Hi everyone;

Please note: Links in this post have been updated to the external scripts for the latest distribution of Price Tapestry (11/09A). Links for the external scripts for the original distribution (01/06A) can now be found in this post.

Just thought i'd collate information from several recent threads regarding showing search and / or price comparison results from your Price Tapestry database within the content of other websites running on the same web server (for example a site running Wordpress, Drupal or Joomla).

To facilitate this, I have created new versions of the main search script (search.php) and the price comparison script (products.php) that do not rely on being called from within the directory in which Price Tapestry is installed.

Search Results

searchExternal.zip

Unzip, and upload searchExternal.php to your Price Tapestry installation folder. Then, to show search results within any other PHP script running on the same web server (it doesn't have to be the same domain name or even a sub-domain, it can be completely different), simply insert the following PHP code into your script:

<?php
  $common_baseHREF 
"http://www.example.com/pricetapestry/";
  
$common_path "/path/to/pricetapestry/";
  
$_GET["q"] = "Search Terms";
  require(
$common_path."searchExternal.php");
?>

Simply edit "Search Terms" to be the query you want to include search results for. Remember that you can use the various search modifiers; for example "merchant:Some Merchant" or "category:Widgets" or "brand:Megacorp" etc.

$common_baseHREF must contain the full URL of the Price Tapestry installation, and is used to overwrite $config_baseHREF which otherwise would only generate a relative URL, which would cause the links to be incorrect if being called from another site.

$common_path must contain the actual file system path to the Price Tapestry installation, starting at the root directory ("/"). If you are not sure what this should be, you can discover it using the following trick. Create a file in your Price Tapestry installation directory called whereami.php with the following code:

<?php
  $path 
$_SERVER["SCRIPT_FILENAME"];
  
$path str_replace("whereami.php","",$path);
  print 
$path;
?>

Then, browse to this script, for example (if Price Tapestry is installed in a directory called /shopping/):

http://www.example.com/shopping/whereami.php

...and something like this will be displayed:

/home/someuser/htdocs/shopping/

...and that is what you would enter for $common_path; for example:

  $common_path = "/home/someuser/htdocs/shopping/";

Price Results

pricesExternal.zip

Again, simply unzip and upload pricesExternal.php. Invocation code from any other PHP script on the same server is almost identical to the above, for example:

<?php
  $common_baseHREF 
"http://www.example.com/pricetapestry/";
  
$common_path "/path/to/pricetapestry/";
  
$_GET["q"] = "Product Name";
  require(
$common_path."pricesExternal.php");
?>

In this case, replace "Product Name" with the exact product name that you wish to display the price comparison table for.

Search Form

Several users have asked how to create a search form from a higher level directory on their site than that in which Price Tapestry is installed. Since the search form dynamically generates a fully qualified URL, the easiest way to do this is to browse to the Price Tapestry folder and then use View > Source in your web browser to view the HTML. Then, simply copy the code between (and including) the <form> tags; and paste this into the HTML (or a "content unit" if using a CSM) of your higher level website.

If you wanted to use the search form on another domain; you would need to replace the action='' attribute of the form tag with the full URL; so if the existing code contained:

action='/shopping/search.php'

...then simply replace this with:

action='http://www.example.com/shopping/search.php'

Submitted by npaitken on Wed, 2008-10-08 11:45.

Hi David,

I tested your pricesExternal.php script above in a higher level folder from my Price Tapestry installation and it works fine.

As I'm using Wordpress in top level folder, I've installed a Wordpress plugin (Exec-PHP) which allows you to execute php code in Wordpress posts - I tested it with some simple php code and it seems to work fine. However, when I try to run the prices code in a Wordpress post I get the following error in the displayed post:

Fatal error: Cannot redeclare translate() (previously declared in /homepages/2/**********/htdocs/wp-includes/l10n.php:67) in /homepages/2/**********/htdocs/shopping/includes/translate.php on line 5

Any thoughts?

Thanks,
Neil

Submitted by support on Wed, 2008-10-08 14:46.

Hi Neil,

If any Price Tapestry external module that calls in the require()'d includes is called twice, you will get this re-declaration error.

What you will need to do is modify the code in pricesExternal.php to check for a previous include and only include the files if necessary. The easiest way to do this would be to check for one of the configuration variables. To do this, simply change the following block of code - right at the top:

  require($common_path."config.php");
  require($common_path."includes/javascript.php");
  require($common_path."includes/tapestry.php");
  require($common_path."includes/translate.php");
  require($common_path."includes/database.php");

to the following:

  if (!$config_databaseServer)
  {
  require($common_path."config.php");
  require($common_path."includes/javascript.php");
  require($common_path."includes/tapestry.php");
  require($common_path."includes/translate.php");
  require($common_path."includes/database.php");
  }

That should fix it!

Cheers,
David.

Submitted by npaitken on Wed, 2008-10-08 15:52.

Hi David,

Still having problems after changing pricesExternal.php

Fatal error: Cannot redeclare translate() (previously declared in /homepages/2/d242783625/htdocs/wp-includes/l10n.php:67) in /homepages/2/d242783625/htdocs/shopping/includes/translate.php on line 5

It seems to be conflicting with Wordpress includes file l10n.php:67 - code down to line 67 below:

<?php
/**
 * WordPress Translation API
 *
 * @package WordPress
 * @subpackage i18n
 */
/**
 * get_locale() - Gets the current locale
 *
 * If the locale is set, then it will filter the locale
 * in the 'locale' filter hook and return the value.
 *
 * If the locale is not set already, then the WPLANG
 * constant is used if it is defined. Then it is filtered
 * through the 'locale' filter hook and the value for the
 * locale global set and the locale is returned.
 *
 * The process to get the locale should only be done once
 * but the locale will always be filtered using the
 * 'locale' hook.
 *
 * @since 1.5.0
 * @uses apply_filters() Calls 'locale' hook on locale value
 * @uses $locale Gets the locale stored in the global
 *
 * @return string The locale of the blog or from the 'locale' hook
 */
function get_locale() {
global $locale;
if (isset($locale))
return apply_filters( 'locale', $locale );
// WPLANG is defined in wp-config.
if (defined('WPLANG'))
$locale = WPLANG;
if (empty($locale))
$locale = 'en_US';
$locale = apply_filters('locale', $locale);
return $locale;
}
/**
 * translate() - Retrieve the translated text
 *
 * If the domain is set in the $l10n global, then the text is run
 * through the domain's translate method. After it is passed to
 * the 'gettext' filter hook, along with the untranslated text as
 * the second parameter.
 *
 * If the domain is not set, the $text is just returned.
 *
 * @since 2.2.0
 * @uses $l10n Gets list of domain translated string (gettext_reader) objects
 * @uses apply_filters() Calls 'gettext' on domain translated text
 * with the untranslated text as second parameter
 *
 * @param string $text Text to translate
 * @param string $domain Domain to retrieve the translated text
 * @return string Translated text
 */
function translate($text, $domain = 'default') {

Any further thoughts?

Neil

Submitted by support on Thu, 2008-10-09 08:38.

Hello Neil,

The first thing I would do is check to see whether the WordPress installation relies on the translate function by editing that file, and just changing the function name with an underscore - for example:

function _translate($text, $domain = 'default') {

If that stops WordPress from working at all; then the only thing to do will be to modify the pricesExternal parts of Price Tapestry so that they do not require the translate function.

To do this, first edit pricesExternal.php and delete the following code from line 8:

require($common_path."includes/translate.php");

..and then remove the calls to translate("text") within the file to just "text". (use your editors search function to find them) - for example on line 41 you will find:

translate("Reviews")

...replace this with just:

"Reviews"

Then do the same in html/prices.php, and this will remove the need for Price Tapestry to use translate() and it should work fine!

Cheers,
David.

Submitted by jonny5 on Sat, 2008-10-18 15:07.

Hi David, how can i do the same but with the featured items? so they display on an upper level/or another site

Submitted by support on Sun, 2008-10-19 13:49.

Hi Jonny,

I just made a featuredExternal.php that works in exactly the same way. Invoke using:

<?php
  $common_baseHREF 
"http://www.example.com/pricetapestry/";
  
$common_path "/path/to/pricetapestry/";
  require(
$common_path."featuredExternal.php");
?>

Cheers,
David.

Submitted by jonny5 on Sun, 2008-10-19 13:55.

topman

cheers

Submitted by jonny5 on Sun, 2008-10-19 20:14.

any ideas where i add the below when using the featuredexternal.php?

$sql = "SELECT merchant FROM `".$config_databaseTablePrefix."feeds` ORDER BY RAND() LIMIT 1";
database_querySelect($sql,$result);
$merchant = $result[0]["merchant"];
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY RAND() LIMIT 3";

Submitted by support on Mon, 2008-10-20 09:46.

Hi Jonny,

Just replace line 47:

$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY sequence";

...with that block of code - that should do the trick!

Cheers,
David.

Submitted by jonny5 on Mon, 2008-10-20 10:00.

ok that works , but i also need the count to work , ie show 1 item then start a new line , this is in the featureed.php but not working with the above mod now

Submitted by support on Mon, 2008-10-20 10:02.

Hi jonny,

Did you have a different HTML moduled called at the bottom of index.php? featuredExternal.php calls in html/featured.php; so it should display in the same way; but if you have a different version - you could just replace the call at the end of featuredExternal.php to the new version...

Cheers,
David.

Submitted by gadget on Wed, 2008-11-05 07:49.

Hi David.

Submitted by support on Wed, 2008-11-05 11:26.

Hi Mark,

I just followed up by email a little while ago...

Cheers,
David.

Submitted by paul30 on Thu, 2008-11-13 22:55.

Remember that you can use the various search modifiers; for example "merchant:Some Merchant" or "category:Widgets" or "brand:Megacorp" etc.

Hello David, I dont understand... How should I apply modifiers if I want to call Category + brand?

I tried something like:

$_GET["q"] = "category:Category Name:brand:Brand name";
and
$_GET["q"] = "category:Category Name&brand:Brand name";

but none of those worked...

Thanks in advance!
Pasha

Submitted by support on Fri, 2008-11-14 04:47.

Hi Pasha,

It won't work quite like that i'm afraid, but is easy to do. In your calling code, to do a category & brand combination search, specify the brand separately, like this:

  $_GET["q"] = "category:Some Category";
  $_GET["brand"] = "Brand";

Then, in searchExternal.php, look for the following code on line 87:

  $where = " ".$parts[0]."='".database_safe($parts[1])."' ";

...and REPLACE this with:

  $where = " ".$parts[0]."='".database_safe($parts[1])."' ";
  if ($_GET["brand"]) $where .= " AND brand='".database_safe($_GET["brand"])."' ";

Cheers,
David.

Submitted by paul30 on Fri, 2008-11-14 06:34.

Thanks a lot! - As usual, it works like a charm!
Cheers!

Submitted by mally on Sun, 2008-11-23 22:47.

Hello David

I've tried adding the above code but I'm getting this error, any idea's?

Warning: require() [function.require]: open_basedir restriction in effect. File(/home/******/public_html/searchExternal.php) is not within the allowed path(s): (/home/*****:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/*****/public_html/index.php on line 38
Fatal error: Can't load /home/******/public_html/searchExternal.php, open_basedir restriction. in /home/******/public_html/index.php on line 38

Submitted by support on Mon, 2008-11-24 09:14.

Hi Mally,

This is a security setting within the PHP configuration that is preventing PHP from being allowed to open (require) a file outside of it's own user / directory structure. If you have control over your PHP configuration (which I think you do from our previous emails) look for the open_basedir directive in php.ini (or an equivalent php_flag in .htaccess) and either comment out or delete that line to remove the restriction. You would need to restart Apache/PHP for the changes to take effect...

Cheers,
David.

Submitted by mally on Sun, 2009-01-04 12:23.

Hello David

Not sure if there's a solution for this but my hosting company have said no to the above saying it would give access to my folders for other people on my server

Cheers

Mally

Submitted by support on Mon, 2009-01-05 09:36.

Hi Mally,

It should still work with a relative path, for example, instead of:

  $common_path = "/path/to/pricetapestry/";

...something like:

  $common_path = "../pricetapestry/";

...or even just:

  $common_path = "pricetapestry/";

...if your CMS is in the root directory and Price Tapestry is installed in a directory called /pricetapestry/...

Cheers,
David.

Submitted by babrees on Mon, 2009-01-26 05:32.

Hi David

Just what I was looking for! But to take it one step further, can I display those from a specific merchant? So when I am writing about a merchant on a level above price tapestry I can feature just their products randomly?

hmm, thinking about it, it might be nice in future to be able to feature a merchant's product on a keyword too if I wanted to!

---------
Jill

Submitted by support on Mon, 2009-01-26 09:23.

Hi Jill,

Sure - just a couple of changes to searchExternal.php and then adding a sort parameter to your calling code should do the trick. Firstly, in searchExternal.php, replace the following code on line 54:

$sort = "relevance";

...with:

$sort = (isset($_GET["sort"])?$_GET["sort"]:"relevance");

Then, look for the following code on line 60:

    $orderByDefault = array();

...and REPLACE this with

    $orderByDefault = array();
    $orderByDefault["rand"] = "RAND()";

Having made those changes, in your calling code where you currently have:

  $_GET["q"] = "merchant:Some Merchant";

...you can now use:

  $_GET["q"] = "merchant:Some Merchant";
  $_GET["sort"] = "rand";

You can already add a keyword to the merchant search using:

  $_GET["q"] = "merchant:Some Merchant:Keyword";

Cheers,
David.

Submitted by jonny5 on Wed, 2009-02-18 18:34.

Hi David , im just looking into using PT and wordpress together.

Ive got featured items displayed ok on the front of the wordpress site , I have the search form on the wordpress site and that works , but what i was wondering was how can the Product.php and the searchresult.php be displayed in wordpress , ie. when u click the featured item or search for a product it will just display in the pricetapestry site and not the wordpress.

not sure if this is possible or if it has already been covered but would be great to be able to do.

thanks in advance

Submitted by support on Wed, 2009-02-18 20:52.

Hello Jonny,

I am currently working on a combined external script that will display the entire Price Tapestry generated content within your WordPress / Joomla page etc. I would be happy to let you try a "beta" version. Could you perhaps email me with the exact calling code that you are currently pasting into your WordPress page(s), and I'll email you back something to try...
Cheers,
David.

Submitted by jonny5 on Wed, 2009-02-18 21:01.

have emailed u

Submitted by richard on Thu, 2009-02-19 20:53.

Hi David

I too have dropped you an email w.r.t beta test, hope that is ok!

Regards

Richard

Submitted by richard on Fri, 2009-02-20 10:52.

Hi David

Works a treat.

Many thanks

Submitted by npaitken on Fri, 2009-03-06 13:40.

Hi David,

Finally got back to this and got it working by stripping out the translate() in the various files.

I have a number of Wordpress posts where I've written say a top 10 products article and wanted to display particular PT information after each product section in the article. Like below

Product 1
Some text here talking about how wonderful product 1 is:

(PT code to show following details for Product 1)
Title
Image
price
more information

Product 2
Some text here talking about how wonderful product 2 is:

(PT code to show following details for Product 2)
Title
Image
price
more information

and so on.....

The problem I've got at the minute is I can't seem to get the desired display result I'm after using searchExternal.php or pricesExternal.php

Using searchExternal.php:
This formats it properly but the search result pulls in too many products. In my case I just want to pull in product 1 or product 2.

Perhaps there's a way I can write more specific searches to get search result to the exact product?

Using priceExternal.php:
This gives me the exact product but displays as a table of prices which isn't really what I'm after here.

Hope there's a simple fix to this?

Best,
Neil

Submitted by support on Fri, 2009-03-06 14:19.

Hi Neil,

I've just replied to your email regarding the "full" version - that will enable you to show the product page for a specified product (or you can include it more than once for multiple products). As it stands, it will show the prices table, but that can be easily remove - i'll indicate how in my email...

Cheers,
David.

Submitted by npaitken on Fri, 2009-03-06 15:28.

Hi David,

Thanks for sending me the "full" version - just sent you an email with problem! Please don't spend too much time tring to fix.

The main thing I'm interested in right now is being able to display just:

TITLE
IMAGE
PRICE
MORE INFO LINK

searchExternal.php does exactly what I'm looking for. Only problem is I can't seem to filter to just a single product.

Make sense?

Thanks,
Neil

Submitted by support on Fri, 2009-03-06 15:33.

Hi Neil,

I sent a follow up to your email regarding the full version.

With regards searchExternal.php, you could modify this to only return 1 result (i'm assuming the product you want is always first). In that file, look for the following code on line 52:

  $page = 1;

...and REPLACE with:

  $page = 1;
  $config_resultsPerPage = 1;

...and that should do the trick!

Cheers,
David.

Submitted by npaitken on Fri, 2009-03-06 16:22.

That works well!

I've actually created two file searchExternal.php and searchExternal_single.php, the second of which returns just the 1 search result. That way I have more options for writing posts.

Thanks again David - brilliant support!

Submitted by npaitken on Fri, 2009-03-06 16:30.

One more thing David!

When using searchExternal.php is it possible to make the images of the products displayed larger. At the minute I get images that are 75x75. For Wordpress posts it would look much nicer if I could make them larger say 200x200.

Thanks,
Neil

Submitted by support on Sat, 2009-03-07 06:11.

Hi Neil,

Sure. As it stands, searchExternal.php calls the existing html/searchresults.php, in which the image size is dicated on line 10 (look for width='80' but may have changed in your template).

What I would do if you want to keep the current sizes on the main site but use a larger image for the external version, is to make a copy of html/searchresults.php and call it, say, html/searchresults_external.php. In that version, change the image size as required.

Then, in searchExternal.php, look for the following code around line 255:

require($common_path."html/searchresults.php");

...and REPLACE that with:

require($common_path."html/searchresults_external.php");

Cheers,
David.

Submitted by npaitken on Mon, 2009-03-09 12:00.

Hi David,

You're a mind-reader! That's exactly what I'm after.

Many thanks,
Neil

Submitted by jonny5 on Mon, 2009-03-16 18:19.

Hi David

not really pricetapestry related but I have used the same idea to display in wordpress some other info and it displays fine but when i click a link it dosent work , i guess i need a php file like external.php so that the link clicks through and displays in the post where the script is.

any idea what I would need to add to a external php file to make it display in the same post ?

Submitted by support on Mon, 2009-03-16 18:47.

Hi Jonny,

When I developed external.php, I found that using a parameter called "p" in the URL broke Wordpress, because it used the $p variable itself - so look out for the that.

Subsequent versions of the script will use a prefix in the URL variables, just like with the database settings.

Basically, you need to look at the URL when you click on one of your embedded links, and then try to understand how the embedded script is seeing those variables. Make sure you are using $_GET["varname"] instead of just $varname etc..!

Cheers,
David.

Submitted by DanielWestman on Thu, 2009-03-26 07:57.

Hi David,

I have the searchform in the header of a wordpress website and yesterday I noticed the search doesn´t work. I´ve made alot of changes to search.php so I dont know how it will end if I use your searchexternal.php. Is there alot of work involved, or could you make the neccessary changes to make my search.php into a searchexternal.php? As it is now, I get this error:

Fatal error: Call to undefined function database_queryselect() in /home/daw/public_html/mysite.org/html/footer.php on line 29

Submitted by support on Thu, 2009-03-26 08:43.

Hi Daniel,

Sure - if you want to email me the searchexternal.php that you are currently using, and your modified search.php from your site i'll try and retro-fit all your mods to search.php into searchexternal.php for you (it's a reasonably distinct block so should be straight forward).

Regarding the error in footer.php - that's strange - is that happening on your normal Price Tapestry install, and if so what page? It implies that the common includes have not been "required()" at the top of whatever script is calling html/footer.php - if you could let me know the URL where this is being displayed that will help...

Cheers,
David.

Submitted by maxbear on Sun, 2009-03-29 16:33.

It seems the saerch in pricesExternal is an Exact Phrase search in the product name. Can I have a board search instead? Thanks.

Submitted by support on Sun, 2009-03-29 17:49.

Hi,

It's exact match because prices.php is essential the product page from within Price Tapestry, so it needs an actual product to select the prices for. Is possible to use searchExternal.php instead of pricesExternal.php in this case?

Cheers,
David.

Submitted by maxbear on Mon, 2009-03-30 10:56.

Hi David,

Yes, no problem. I might use searchExternal.php to do price comparison.

One more question for pricesExternal.php, different merchants call the product differently. For example:

1. Product A
2. Product A very good
3. Prodcut A the best

If 3 merchants call product A differently (they are actually the same product), how can I includes all these 3 in pricesExternal.php?

Thanks.

Submitted by support on Mon, 2009-03-30 11:09.

Hi,

Have you looked at using Product Mapping to give all those products the same name? In this case, if "Product A" is he most obvious name for the product, in /admin/, go to Product Mapping and add "Product A" as a new product. Then, on the next page, enter

Product A very good
Product A the best

(on separate lines) and then Save the mapping. After you have then imported all affected feeds, they will all be called "Product A"

Hope this helps!

Cheers,
David.

Submitted by maxbear on Mon, 2009-03-30 12:01.

Thanks a lot David.

Submitted by jonny5 on Mon, 2009-03-30 13:16.

David , now that im using the searchexternal file the product url is as below , would you know what changes to make to the HTaccess to have SEO urls? I have tried a number of things but they do not work.

/website/?product=Apple+iPhone+3G+8GB

thanks in advance

Submitted by support on Mon, 2009-03-30 14:15.

Hi Jonny,

Could you email me your external.php and also the .htaccess that will be in scope from wherever it is running and I'll try and work out what you'll need...

Cheers,
David.

Submitted by Paul1107 on Mon, 2009-03-30 19:52.

Hi David,

I'm getting this also...

I'm using your external.php wordpress/joomla beta plugin

Thanks

Paul

Submitted by support on Mon, 2009-03-30 20:02.

Hi guys,

Thanks for the feedback - i'll look at how search engine friendly URLs can be incorporated when being called from an external script - it's not straight forward as I'm sure you can imagine as the calling script (e.g. WordPress or Joomla) is ultimately responsible for the URL and how it is handled, but there should be ways round it...

Cheers,
David.

Submitted by Paul1107 on Mon, 2009-03-30 21:16.

Hi David,

Don't know whether it helps, but another Wordpress site that you helped me with last year where I am using SearchExternal.php has a more friendly URL www.mydomain/store/jump.php?id=123456

thanks

Paul

Submitted by jonny5 on Sat, 2009-05-16 11:14.

Hi David , wondering if you may have had any other ideas on the seo urls , ive been searching for a solution but no luck , can either get seo urls of the wordpress installation or seo urls of the products from pricetapestr but not both together.

or has anyone else had any luck?

Submitted by support on Sun, 2009-05-17 07:49.

Hello Jonny,

It would involve re-writing the search engine friendly URLs within your WordPress pages to the appropriate internal WordPress URL that is displaying products via pricesExternal.php. If you could perhaps email me an example of the URLs you would like and the equivalent WordPress URL I'll work out the rules for you...

Cheers,
David.

Submitted by jonny5 on Wed, 2009-05-20 18:05.

David , many thanks for the emails regarding the SEO friendly urls , i was a right pain bugging u :) i have now got it working and will send u the details in a email when i get 5 mins, as u will understand unlike me :) and then if others need to know then u have the info

cheers for all the help

Submitted by Mark on Sun, 2009-06-07 09:56.

Hi David - is there a way to add a search box to a site on a different server from the one that the database is?
Mark

Submitted by Mark on Sun, 2009-06-07 10:41.

I've resolved the last question I asked on this thanks

Submitted by npaitken on Tue, 2009-06-16 17:00.

Hi David,

Quick question regarding using PricesExternal.

Just started using this again and I think it's great. However, I'd like to have the merchant logos appear in the PricesExternal results in Wordpress, just like they do in Price Tapestry.

I've managed in get everything else looking similar in Wordpress by wrapping the table in prices.php with a DIV and styling it accordingly in my Wordpress css file.

<div class="PricesExternal">
  <table>
    <tr>
      <th><?php print "Store"?></th>
<th>&nbsp;</th>
      <th><?php print "Description"?></th>
      <th><?php print "Price"?></th>
    </tr>
    <?php foreach($prices["products"] as $product): ?>
    <tr>
      <td><a href='<?php print $product["merchantHREF"]; ?>' title='<?php print $product["merchant"]; ?>'><?php print $product["merchant"]; ?></a></td>
<td>
      <?php
      if (file_exists("logos/".$product["merchant"]))
      {
        print "<img src='".$config_baseHREF."logos/".$product["merchant"]."' />";
      }
      else
      {
        print "&nbsp;";
      }
      ?>
      </td>
      <td><a href='<?php print tapestry_buyURL($product); ?>' title='<?php print "Visit Store"?>' <?php print javascript_statusBar("Go to ".$product["merchant"]); ?>><?php print $product["name"]; ?></a></td>
      <td><a href='<?php print tapestry_buyURL($product); ?>' title='<?php print "Visit Store"?>' <?php print javascript_statusBar("Go to ".$product["merchant"]); ?>><?php print $config_currencyHTML.$product["price"]; ?></a></td>
    </tr>
    <?php endforeach; ?>
  </table>
</div>

But, how do I get the logos to appear? They're sitting in a subfolder /logos/ of my Price Tapestry install.

Thanks,
NEil

Submitted by support on Wed, 2009-06-17 04:47.

Hi Neil,

It should just be a case of changing:

      if (file_exists("logos/".$product["merchant"]))

to...

      if (file_exists($common_path."logos/".$product["merchant"]))

Cheers,
David.

Submitted by npaitken on Wed, 2009-06-17 14:22.

HI David,

That worked great for PricesExternal, BUT, it made the logos disappear on my PT site! Is there a way to make logos appear on both?

Thanks,
Neil

Submitted by support on Wed, 2009-06-17 14:28.

Hi Neil,

I was expecting that to work in both instances, because when viewing
the normal Price Tapestry site $common_path should be empty, so the
tested file will be the same.

Perhaps the easiest thing to do is to make the file_exists() call use
the full path regardless, so in other words, take the value that you
are using as $common_path in your calling code, and prefix that to
logos/, so that you have:

   if (file_exists("/full/path/to/logos/".$product["merchant"]))

That should do the trick!

Cheers,
David.

Submitted by npaitken on Thu, 2009-06-18 14:32.

mmmhh....Now the logos have dissapeared from both Wordpress & Price Tapestry!

Further thoughts?

Thanks Neil

Submitted by support on Thu, 2009-06-18 14:39.

Hi Neil,

Could you email me the file over i'll check it out!

Cheers,
David.

Submitted by steve on Fri, 2009-06-26 16:56.

Hi David,

I can't seem to be able to add two separate price comparison tables (with different products) on the same page.

When I add the second code block below, the second "q" phrase is ignored and it just duplicates the product table of the first bit of code.

<?php
  $common_baseHREF 
"http://www.domain.co.uk/comparison/";
  
$common_path "/home/www/domain.co.uk/comparison/";
  
$_GET["q"] = "second phrase";
  require(
$common_path."pricesExternal.php");
?>

Thanks in advance :-)

Steven

Submitted by support on Fri, 2009-06-26 17:06.

Hi Steve,

Try using:

<?php
  $prices 
= array();
  
$common_baseHREF "http://www.domain.co.uk/comparison/";
  
$common_path "/home/www/domain.co.uk/comparison/";
  
$_GET["q"] = "second phrase";
  require(
$common_path."pricesExternal.php");
?>

Cheers,
David.

Submitted by frozenwaste on Wed, 2009-07-29 00:59.

Hi David,

Trying to get PT to show on my WordPress site. I've uploaded searchExternal.php to the PT installation folder on my site. Using your whereami.php script I've identified the common path and I've set the query string to a test query I know works. Here's my config:

<?php
  $common_baseHREF 
"http://www.fashionhype.co.uk/comparison/";
  
$common_path "/var/www/vhosts/fashionhype.co.uk/httpdocs/comparison/";
  
$_GET["q"] = "merchant:Boohoopoo:";
  require(
$common_path."searchExternal.php");
?>

I've added this to my home.php (hompage) just to test, but it's not working and causes the sidebar not to show. Same thing happens if I add the above code to an individual post (using Exec-PHP).

Any ideas?

Thanks,

Peter.

Submitted by support on Wed, 2009-07-29 08:46.

Hi Peter,

It may be a conflict of the translate function. In your searchExternal.php, look for the following code on line 40:

    require($common_path."includes/translate.php");

...and either comment our delete that line. That should do the trick...

Cheers,
David.

Submitted by frozenwaste on Wed, 2009-07-29 13:30.

Hi David,

That worked! Thanks for you help.

Peter.

Submitted by jonny5 on Tue, 2009-09-08 19:36.

Hi David

I have externalfeatured in a sidebar and in a post i have pricesExternal

the prices in the post display but the featured items i get

Fatal error: Cannot redeclare javascript_focus() (previously declared in

any ideas? i know some of the include files are being declared again to get this error

Submitted by support on Wed, 2009-09-09 08:27.

Hi Jonny,

Without seeing the code that you are using to incorporate featured products as well as prices being displayed by pricesExternal.php; check the code that you are using and simply replace each instance of:

require

...with:

require_once

That should sort it!

Cheers,
David.

Submitted by jonny5 on Wed, 2009-09-09 09:21.

many thanks

that worked a treat

Submitted by empiricalWeb on Mon, 2009-09-21 03:23.

This might be a dumb question, but when using the Prices External wrapped in your wordpress CSS, is the URL of the price results still SEO friendly...

i.e. when you display a price within wordpress, is the URL created still by PT or do you have to make your own with WP?

Submitted by support on Mon, 2009-09-21 11:56.

Hi,

The URL is created by WordPress - in fact it's the same URL of the page that you place the calling code into, so it can be made search engine friendly by way of WordPress' built in clean URL features...

Cheers,
David.

Submitted by babrees on Tue, 2009-09-22 16:35.

At the moment the searchExternal.php displays the results in alphabetical order. Is it possible to show them in price - low to high order?

---------
Jill

Submitted by support on Tue, 2009-09-22 16:43.

Hi Jill,

In searchExternal.php you should find on line 54:

  $sort = "relevance";

(relevance doesn't actually apply if the search code does not end up using the full text index which is why you will see alphabetical results)

...change that to:

  $sort = "priceAsc";

That should do the trick!

Cheers,
David.

Submitted by babrees on Tue, 2009-09-22 17:39.

Perfect! As usual! Thanks David!

---------
Jill

Submitted by Leo on Mon, 2009-11-02 12:14.

Hi David

Get same error as Mally with 2 different domains on same server (reseller account)
Have no access to php ini, guess not easy to use than on different domains?

Greets,
Leo

Submitted by support on Mon, 2009-11-02 12:28.

Hi Leo,

Did you try changing $common_path from an absolute to a relative path, described in this comment...

http://www.pricetapestry.com/node/2289#comment-10205

If you're not sure what the values should be; if perhaps you could email me a links to both the Price Tapestry installation and the page on which you are including the "calling code"; and also a copy of the calling code that you are using I'll check it out for you...

Cheers,
David.

Submitted by jim on Thu, 2009-11-26 08:17.

Hi David,

I have a similar problem as jonny5 posted on Tue, 2009-09-08 19:36

I have two separate PT installs in:

example.com/folder1/
example.com/folder2/

Then, on a completely different website I am trying to use two searchExternal.php bits

The second one won't work, it displays results from /folder1/ in both cases.

- I tried changing all occurences of require to require_once in both versions searchExternal.php files
- I also tried adding the $prices = array(); trick to the 2nd block
- I tried the extra code you suggested: if (!$config_databaseServer) {require_once($common_path."config.php"); require_once($common_path."includes/javascript.php"); etc... }

<?php
    $common_baseHREF = "http://www.example.com/folder1/";
    $common_path = "/home/xxx/public_html/folder1/";
    $_GET["q"] = "redwidgets";
    require($common_path."searchExternal.php");
  ?>

<?php
 $prices = array();
    $common_baseHREF = "http://www.example.com/folder2/";
    $common_path = "/home/xxx/public_html/folder2/";
    $_GET["q"] = "bluewidgets";
    require($common_path."searchExternal-grid.php");
  ?>

any ideas what I'm doing wrong?

Submitted by support on Thu, 2009-11-26 10:30.

Hi Jim,

I'm assuming that both snippets are on the same page - in which case what is happening is that that config.php is not being re-loaded the second time; so searchExternal.php will continue to use the /folder1/ installation's database.

To fix this; replace your second snippet with:

<?php
    $common_baseHREF 
"http://www.example.com/folder2/";
    
$common_path "/home/xxx/public_html/folder2/";
    
$_GET["q"] = "bluewidgets";
    require(
$common_path."config.php");
    require(
$common_path."searchExternal-grid.php");
?>

Hope this helps!

Cheers,
David.

Submitted by jim on Fri, 2009-11-27 11:21.

thanks David, that solved the problem :)

Submitted by support on Wed, 2010-01-27 11:23.

Hi everyone,

Here are updated external scripts for use with the latest distribution
of Price Tapestry...

searchExternal.zip (old version)

pricesExternal.zip (old version)

featuredExternal.zip

Inline with the latest distribution, searchExternal.php may include
minPrice and/or maxPrice parameters, for example:

<?php
  $common_baseHREF 
"http://www.example.com/pricetapestry/";
  
$common_path "/path/to/pricetapestry/";
  
$_GET["q"] = "Search Terms";
  
$_GET["minPrice"] = "50.00";
  
$_GET["maxPrice"] = "100.00";
  require(
$common_path."searchExternal.php");
?>

Example calling code for the new featuredExternal.php script:

<?php
  $common_baseHREF 
"http://www.example.com/pricetapestry/";
  
$common_path "/path/to/pricetapestry/";
  require(
$common_path."featuredExternal.php");
?>

featuredExternal.php also supports the section modification from
this thread. The section name should supplied through the
$common_featuredSection variable; for example:

<?php
  $common_baseHREF 
"http://www.example.com/pricetapestry/";
  
$common_path "/path/to/pricetapestry/";
  
$common_featuredSection "PS3";
  require(
$common_path."featuredExternal.php");
?>

...which will display only Featured Products specified as, for
example:

PS3/Product Name

Cheers,
David.

Submitted by alank on Wed, 2010-01-27 16:18.

works perfect, thanks David

Alan

Submitted by dflsports on Sun, 2010-01-31 16:50.

having trouble gettign results to show on another site, on the same server. I nave not yet upgraded to the latest version of PT.

error:

Warning: require(/home/XXXXXX/public_html/searchExternal.php) [function.require]: failed to open stream: Permission denied in /home/XXXXXX/public_html/index.php on line 153

Fatal error: require() [function.require]: Failed opening required '/home/XXXXXX/public_html/searchExternal.php' (include_path='.:/usr/local/php5/lib/php') in /home/XXXXXXX/public_html/index.php on line 153

Not sure how to proceed.

The paths are correct in the bit of code I added to the external site:

<?php
  $common_baseHREF 
"http://www.hockeyshopper.com/";
  
$common_path "/home/XXXXXX/public_html/";
  
$_GET["q"] = "goalie pads";
  require(
$common_path."searchExternal.php");
?>

PT installed in root directory.

Thanks!

Don

Submitted by support on Mon, 2010-02-01 10:09.

Hi Don,

This implies that the 2 sites are configured under separate user IDs and they do not have read access to other user's directories. I'm assuming for example that you have this kind of setup:

/home/user1/public_html/ (existing Price Tapestry site)
/home/user2/public_html/ (site where you are trying the external code)

...and that user2 does not have READ access to user1's home directory.

First check whether your hosting control panel has a permissions area from which you can modify user1 permissions to give user2 read access - that should do the trick; but check with your host if you're not sure.

If it doesn't look like it would be possible; there is an alternative method; and that is to create a "ghost" installation of Price Tapestry in a sub-directory, e.g. "pt". In config.php; simply use the same database settings as your main Price Tapestry site; not forgetting to make $config_baseHREF = "pt";

In the calling code; leave $common_baseHREF as it is (so that the links go to your main Price Tapestry site); but simply change $common_path to be the path to the ghost installation; which then shouldn't have any permission issues...

Hope this helps!

Cheers,
David.

Submitted by dflsports on Mon, 2010-02-01 16:40.

Turns out my host has disabled account sharing due to security concerns. I may try method 2. Or perhaps use some sort of ajax httprequest. Thought about making rss feeds from the main installation and parsing them using magicparser on the other sites. Thanks for the quick response.

Submitted by Henk3001 on Wed, 2010-03-31 19:23.

I imigrate it to joomla and it worked with the standard :

$_GET["q"] = "article";

Now i want that "article" will be the content name can you help me ?

Thx
HEnk

Submitted by support on Thu, 2010-04-01 10:57.

Hello HEnk,

Yes - here is how to do this. In your calling code; add this line:

print_r($GLOBALS);

This will generate lots of output, showing all of the globalvariable names (in [square brackets]) and their values. Study the output, and look for one that contains the content name you want in the q variable, and, let's say it is in the output as [pageTitle] => "Content Name", then in your calling code you would use:

$_GET["q"] = $pageTitle;

(then you can remove the print_r() line of course)

Now, it may be a little more complex if the title is part of an array, or maybe even a PHP object. If you're not sure what the variable name you need to use is; if you could create a test page, with a test "Content Title", and then on that page just have the code

<?php
  print_r
($GLOBALS);
?>

...and then let me know the URL where I can see that online I will work out the variable name you need to use for you...

Cheers,
David.

Submitted by Henk3001 on Thu, 2010-04-01 19:35.

Hi i send you a link to my page.

Thx
Henk

Submitted by Henk3001 on Sat, 2010-04-03 11:33.

Got it working now, is it possiible to have a full text result, see the next link:

{link saved}

When a content item has a name bloc, the result doesn't apear:

{link saved}

Thx
HEnk

Submitted by support on Tue, 2010-04-06 06:41.

Hello Henk,

You could make it use a LIKE query, but bear in mind that you could only use parts of the product name that are still unique to that product, otherwise you will also get other product's prices in the table. To try this, in your pricesExternal.php look for the code around about line 54 where the products are SELECTed:

$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($q)."' ORDER BY price LIMIT ".$config_resultsPerPage;

...and REPLACE with:

$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name LIKE '%".database_safe($q)."%' ORDER BY price";

Hope this helps!

Cheers,
David.

Submitted by Henk3001 on Tue, 2010-04-06 11:52.

Now it doesn't give any result.
maybee i can rebuilt the searchExternal.php file and directly link to the merchant.

HEnk

Submitted by support on Tue, 2010-04-06 12:21.

Hi Henk,

Sorry about that - there was a mistake in the replacement SQL that I
posted above - I have corrected it now (there was an = after LIKE)..

Cheers,
David.

Submitted by henk on Tue, 2010-04-06 12:35.

oooké it work.

For
$_GET["q"] = "Product Name";

you can use

$this->escape($this->params->get('page_title'))

in joomla

Thx
HEnk

Submitted by darren on Wed, 2010-04-21 14:41.

Any idea when this will become a full release?

Submitted by support on Wed, 2010-04-21 14:43.

Hi Darren,

The external scripts for use with the latest version are in this post - I don't plan to incorporate them with the distribution at this time but they're they ready to be used and i'll give you any help needed getting it working...

Cheers,
David.

Submitted by darren on Wed, 2010-04-21 14:49.

Hi David

Sorry I wasn't being clear - I have the external scripts - I was referring to the implementation into wordpress and specifically this part:

"I am currently working on a combined external script that will display the entire Price Tapestry generated content within your WordPress / Joomla page etc. I would be happy to let you try a "beta" version. Could you perhaps email me with the exact calling code that you are currently pasting into your WordPress page(s), and I'll email you back something to try..."

Are you still testing this and is it likely to be openly available in the near future?

Thanks

Submitted by support on Wed, 2010-04-21 16:33.

Hello Darren,

My apologies - the full external scripts ends up being quite heavily customised in every situation but you're welcome to try it. If you could email me a copy of one instance of calling code that you are currently using, and let me know if the site you want to pull data from is running the original or latest distribution of Price Tapestry and I'll send you the full external script with the calling code required for that version...

Cheers,
David.

Submitted by jim on Mon, 2010-05-03 03:03.

Hi David,

I'm working on a new Wordpress/PT niche site and I'm doing all the development offline on my Windows PC using WAMPserver.

I've tried to call in the pricesExternal.php script in a Wordpress post (I have Exec-PHP plugin installed) but I can't seem to get it to work (maybe my paths are wrong? I've tried a few different URLs and paths)

I have Wordpress installed in :
Z:/wamp/www/example/
so I can type into my browser http://localhost/example to see it

and PT is in
Z:/wamp/www/example/shop
so I type in http://localhost/example/shop to see it

I am pasting this code into my Wordpress post:

<?php
  $common_baseHREF = "http://localhost/example/shop/";
  $common_path = "http://localhost/example/shop/";
  $_GET["q"] = "product name";
  require($common_path."pricesExternal.php");
?>

but I see this error:

Notice: Undefined variable: common_path in Z:\wamp\www\example\shop\pricesExternal.php on line 38

Can you see where I'm going wrong?

thanks
Jim

ps. I'd also be interested like Darren to see the Wordpress/PT integration script you've been working on :)

Submitted by support on Tue, 2010-05-04 08:34.

Hi Jim,

This line of your calling code:

  $common_path = "http://localhost/example/shop/";

...should actually be:

  $common_path = "Z:/wamp/www/example/shop/";

As it stands, the require() function would have been trying to include the file by URL, meaning that it would have been parsed and only including the HTML output rather than the actual PHP itself - so that should be all it is.

Drop me an email when that's working with the calling code that is doing the job, and i'll send you the full external.php with the calling code required for that version...

Cheers,
David.

Submitted by jim on Wed, 2010-05-05 05:07.

Yes, that worked. Thank you :)

I may have tried that URL before, when I was trying to figure out what wasn't working, but I've only just realised an error I made...
When using pricesExternal.php does the 'q' value have to exactly match a product name for any prices to be displayed?

When I tried a search for 'widgets' using searchExternal.php it gave me results, but nothing on pricesExternal.php.

Happy days. Thanks David, I'll drop you an email about the full external.php Wordpress code

Submitted by support on Wed, 2010-05-05 06:34.

Hi Jim,

That's correct - the value set in $_GET["q"] must match a product name exactly.

Cheers,
David.

Submitted by crax2 on Sun, 2010-07-04 17:59.

Hi David

I've read through the posts here but cannot find a solution to my problem. First of all: Displaying the price comparison table in Wordpress works perfect - and has solved me some huge problems. Great work! The only thing lacking: I would love to be able to display the best price in a more prominent manner. As the standard script provides the "best price" just below the product's description, I would like to be able to do this using an external system such as wordpress as well.

Any suggestions? Thx in advance,

Simon

Submitted by support on Mon, 2010-07-05 08:21.

Hi Simon,

It's probably best to start making use of the full external.php script; which displays the product page exactly as the main script, and then creating custom html/ files for it to use (e.g. html/productExternal.php) to display as much or as little of the information as your require, with whatever prominence you wish to give to each section, such as the Best Price.

The quickest way to get started would be if you could email me the calling code that you have derived for use with pricesExternal.php, i'll then email the full script to you with the calling code required for that version...

Cheers,
David.

Submitted by pieter on Tue, 2010-08-24 13:26.

Hi David,

Is it possible to use a paginator with searchExternal.php?
Tried to modify it by including navigation.php etc., but that doesn't do the trick.

Cheers,

Pieter.

Submitted by support on Tue, 2010-08-24 13:30.

Hi Pieter,

You'll need the full external.php to use navigation. Can you email me the calling code (the PHP that you added to your external site) to call searchExternal.php and I'll reply with external.php and the code required for that version...

Cheers,
David.
--
PriceTapestry.com

Submitted by pieter on Tue, 2010-08-24 13:46.

Ah, ofcourse!

That explains, I used $_GET["q"] to call searchExternal.php, but it works fine when using this with external.php.

Thanks,

Pieter.