Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Detecting Second Level Category Names


NinjaNoodles

Recommended Posts

Posted

After a few hours, this is the only way I could detect second level category names.

 

I've modified the script so it converts this name into a file path, and includes a file into the page. That way, each category can include its own unique file.

 

<?php 
$spbname = preg_replace("/[^a-zA-Z0-9s]/", "", strip_tags(strtolower(end(explode("-", $breadcrumb->trail('-')))))); 
$spbfile = "catpages/".$spbname.".php"; 
if (file_exists($spbfile)){ 
include "$spbfile"; 
} 
?>

 

That being said, is there an easier way? $category['categories_name'] only works on first level categories.

Posted

what's the purpose of having multiple files for the categories? Consumes more disk space and there is more maintenance to it, but I believe that's not what you're aiming for.

Posted

What I've done is added the ability to have a unique page included into each category. So if the category is called "Category A," the page categorya.php will be included. If the page doesn't exist, the script will simply move on.

Posted

why not using an SEO module instead? The purpose of using php with osC is to dynamically generate pages using just few main scripts.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...