You are here:  » Add a product info page

Support Forum



Add a product info page

Submitted by Patate on Tue, 2007-05-01 13:37 in

Hi,

I need to add a product info page (with more data about the product, from another database).
For this page, I just need to keep the product name (for the next query).
The url could be /product/info/name-of-product.html

Does someone know how can I add this page ?

Thanks.

Submitted by support on Thu, 2007-05-03 08:59

Hi,

It's pretty straight forward to set up. What you need to do is add something like this to your .htaccess:

RewriteRule ^productinfo/(.*).html$ productinfo.php?q=$1&%{QUERY_STRING} [L]

I would not recommend using product/info/ as this will collide with Price Tapestry's existing rewrite rule for the product page.

Now all you need is your productinfo.php. If you want the page to blend with other Price Tapestry pages, something like this should get you started:

<?php
  
require("includes/common.php");
  
$q $_GET["q"];
  
$banner["h2"] = "Product Information - <strong>".htmlentities($q,ENT_QUOTES,$config_charset)."</strong>";
  require(
"html/header.php");
  require(
"html/menu.php");
  require(
"html/searchform.php");
  require(
"html/banner.php");
  
/************************/
  
Create your product info
  HTML here using normal
  MySQL statements
...
  
/************************/
  
require("html/footer.php");
?>

Throughout the script the product name will then be in the $q variable ready for you to use in display and when constructing the SQL. When creating links back to the product page, remember to use urlencode($q) instead of just $q on its own...

Hope this helps,
Cheers,
David.

Submitted by Patate on Fri, 2007-05-04 21:22

Hi David,

And thank you for your help.
With this htaccess line,
RewriteRule ^productinfo/(.*).html$ productinfo.php?q=$1&%{QUERY_STRING} [L]
it works when I use http://www.domain.com/productinfo/product-name.html.

But when I try to edit it to
RewriteRule ^product<strong>/</strong>info/(.*).html$ productinfo.php?q=$1&%{QUERY_STRING} [L]
to have http://www.domain.com/product/info/product-name.html, I only have header and footer (not the productinfo.php page).

Submitted by support on Sun, 2007-05-06 09:15

Hi,

The problem here is the collision with the main product page rule, which matches anything after /product/, so the whole of "info/product-name" is being taken as the product name.

If should work this way if you move your product/info/ rule above the product/ rule in .htaccess so that it gets picked up first. Try putting it first and see if that helps...

Cheers,
David.

Submitted by Patate on Sun, 2007-05-06 17:41

It's Ok ! Thanks again !