You are here:  » category state

Support Forum



category state

Submitted by SteveC on Wed, 2007-04-25 14:36 in

Hi,

Whats the best way to maintain a category 'state' across a pricetapestry site so that I can apply appropriate text to placeholders in the html?
Ive tried using session variables and couldnt seem to get it to work. Ive also tried appending to the query string in the html anchors and this works great but 'breaks' the friendly url rewrite function.

Thanks, Steve.

Submitted by support on Wed, 2007-04-25 14:45

Hi Steve,

Probably the best way is to study the variables that will contain the category information. The only pages you are really interested in are search.php (which is called for almost every page except the product page) and products.php.

The following block of code should figure out the current category on any page:

<?php
  
// see if we are on a category search page, category is in $parts[1] if so
  
if ($parts[0] == "category")
  {
    
$category $parts[1];
  }
  else 
// we must be on the products page, so get category of first product
  
{
    
$category $product["products"][0]["category"];
  }
?>

If you use this code just before the following line in both files:

  require("html/header.php");

...this should then give you the $category variable to use anywhere else on the page or within the HTML modules...

Hope this helps!
Cheers,
David.