You are here:  » Integrating search results into existing content pages

Support Forum



Integrating search results into existing content pages

Submitted by Excell on Tue, 2007-12-04 10:06 in

Hi, I'm evaluating PT and have following questions:

1) Is it possible to incorporate product search results into existing content pages? For example, I want to have "digital camera" related affiliate links added into a page that has "digital camera" related content.

2) Is it possible to automatically search affiliate products based on keywords pre-set on my pages? For example, my site is a directory-type site that builds php files based on its category name, e.g. pricetapestry.com/digital-camera/. And I use the category name field as the keyword for various applications. Can I search the databse and produce results on an exsiting page by using keyword that automatically assigned to this page?

3) If my keyword is "digital cameraS", can I get search results about "digital camera"?

Thank you so much.

Submitted by support on Tue, 2007-12-04 12:25

Hi,

Thanks for your interest in Price Tapestry. To answer your questions;

1) Is it possible to incorporate product search results into existing content pages? For example, I want to have "digital camera" related affiliate links added into a page that has "digital camera" related content.

There is no specific way to do this, but with a little bit of PHP coding it is easy to use the Price Tapestry libraries to query the database in any way you want and display results from your Price Tapestry installation on any non-Price Tapestry page on your site. The following thread discusses this, and contains example code needed to do this:

http://www.pricetapestry.com/node/1597

That thread specifically concerns top rated or reviewed products, but the items displayed is based entirely on the SQL, so in your instance, you might want to select products from a "Digital Cameras" category:

$sql = "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE category='Digital Cameras' LIMIT 5";

2) Is it possible to automatically search affiliate products based on keywords pre-set on my pages? For example, my site is a directory-type site that builds php files based on its category name, e.g. pricetapestry.com/digital-camera/. And I use the category name field as the keyword for various applications. Can I search the databse and produce results on an exsiting page by using keyword that automatically assigned to this page?

This is pretty much the same as above - all you would need to do is bring the category field from your dynamic page into the SQL. So, if your category is within a variable called $category, the SQL from the above example would simply be changed as follows:

$sql = "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE category='".database_safe($category)."' LIMIT 5";

3) If my keyword is "digital cameraS", can I get search results about "digital camera"?

This is the "stemming" issue. Basically, all you need is a simple modification to take any word in the query that ends in "s", and add the non-plural version to the list of search terms. The code to do this is in the following thread:

http://www.pricetapestry.com/node/617

Hope this helps!
Regards,
David.

Submitted by Excell on Thu, 2007-12-13 14:20

Hi David,

Again I need your assistance. I tried your code and found it extracted results from categories. What I want is to get search result from search.php, for example, I have a digital camera related content page and want to search the whole database with keyword "digital camera" and include the result page (url/shopping/search.php?q=digital+camera) into the content page.

And I want to include the information exactly the same as the search results (url/shopping/search.php?q=keyword), which have image, product name, description, price, etc. By using the codes from http://www.pricetapestry.com/node/1597, I only got links to products.

In short, I want to integrate the search.php results into other pages, how can I do that? Could you give the full codes? I searched the forum and could not find similar solutions.

Thank you.

Excell

Submitted by support on Thu, 2007-12-13 14:24

Hi,

A similar request came up just yesterday - and this morning I posted some code to pull in arbitrary search results into your own page.... which should give a good starting point...

http://www.pricetapestry.com/node/1740

Cheers,
David.

Submitted by Excell on Thu, 2007-12-13 15:09

David, please help me check my code

<?php
  $path_to_pricetapestry = "{link saved}";
  global $config_databaseServer;
  global $config_databaseUsername;
  global $config_databasePassword;
  global $config_databaseName;
  require($path_to_pricetapestry."config.php");
  require($path_to_pricetapestry."includes/tapestry.php");
  require($path_to_pricetapestry."includes/database.php");
  // now preload $_GET["q"] to be the query you want to display search results for
  $_GET["q"] = "digital camera";
  // now bring in the search code
  require($path_to_pricetapestry."searchcode.php");
  // now use Price Tapestry's search results HTML module to display the results
  require($path_to_pricetapestry."html/searchresults.php");
?>

I got this error using above code
Warning: require(../config.php) [function.require]: failed to open stream: No such file or directory in {link saved}/shopping/includes/common.php on line 10

Fatal error: require() [function.require]: Failed opening required '../config.php' (include_path='.:/usr/local/lib/php') in {link saved}/shopping/includes/common.php on line 10

Thank you.

Submitted by support on Thu, 2007-12-13 15:43

Hiya,

Can you double check the path....? I think you might be missing a final directory; as in most configurations there is something like a "wwwroot" or "htdocs" that is the top level directory of your website rather than just the username folder.... For example, instead of:

$path_to_pricetapestry = "/home/username/shopping/";

it might be:

$path_to_pricetapestry = "/home/username/wwwroot/shopping/";
~or~
$path_to_pricetapestry = "/home/username/htdocs/shopping/";

...something like that...

Cheers,
David.

Submitted by Excell on Sat, 2007-12-15 14:00

Hi David,

I found the problem was that I shoud also set the absolute path in includes/common.php. Now I can pull in arbitrary search results with following code

<?php
  $path_to_pricetapestry = "/www/shopping/";
  // now preload $_GET["q"] to be the query you want to display search results for
  $_GET["q"] = "keywords";
  // now bring in the search code
  require($path_to_pricetapestry."searchcode.php");
  require($path_to_pricetapestry."html/searchform.php");
  // and finally the common footer, although you could always add more content first
  require($path_to_pricetapestry."html/footer.php");
?>

Now I have another probem which is not related with PT. On my site the keywords for pulling in search results are the titles converted from following php code
<?php echo ShowTitle(); ?>

However, in $_GET["q"] = "keywords";, this code <?php echo ShowTitle(); ?> is not effective. Is there anyway to make <?php echo ShowTitle(); ?> work in the context?

Thank you for your assistance.

Submitted by support on Sat, 2007-12-15 18:50

Hi,

If ShowTitle() returns the keywords you want to use, you should just be able to do it like this:

  $_GET["q"] = ShowTitle();

Cheers,
David.

Submitted by Excell on Tue, 2007-12-18 13:22

David, I almost succeed in reaching my goal with your assistance. I have the last but perhaps the most difficult problem is that the php value ShowTitle(); in $_GET["q"] = ShowTitle(); doesn't convert into real keywords when searching the mysql database. There is no problem with the code expression, but it doest work in server side.

Can I convert below code into javascript similar to chitika or shopping.com style affiliate js code?

<?php
  $path_to_pricetapestry = "/www/shopping/";
  // now preload $_GET["q"] to be the query you want to display search results for
  $_GET["q"] = ShowTitle();
  // now bring in the search code
  require($path_to_pricetapestry."searchcode.php");
  require($path_to_pricetapestry."html/searchform.php");
  // and finally the common footer, although you could always add more content first
  require($path_to_pricetapestry."html/footer.php");
?>

Or are there any other varieties for $_GET["q"] = ShowTitle();?

Thank you.

Submitted by support on Tue, 2007-12-18 13:39

Hi,

What I think might be happening is that ShowTitle() is actually printing the title directly to the output buffer instead of returning the title as a string.

If you think this is the case, do you have any access to the PHP code for the ShowTitle() function, and might be able to change this?

Cheers,
David.