Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Conditional Formatting in header.php file


ReginaStelling

Recommended Posts

Posted

Hi!

I want to put some code in the header.php to do some conditional formatting based on Category.

 

Is that possible...

 

How can I do this:

 

IF Category = "Ice Cream"

then A

IF Category = "Chili"

then B

IF Category = "Coffee"

then C

Else

D

 

I know a little php...but not sure how to check the category. Is that a URL string I should check??

 

Any help would be GREATLY appreciated!!

Posted
I want to put some code in the header.php to do some conditional formatting based on Category.

 

Is that possible...

Would something like this work? Cases to be filled according to your shop of course.

<?php
if (isset($_GET['cPath']) { // if category = cPath is not in the URL, no reason to go further
switch ($_GET['cPath']) {
case "1_7":
print ("<h1>A. This is for Ice Cream</h1>\n");
break;
case "2" :
print ("<h1>B. This is for Chili</h1>\n");
break;
case "4_21" :
print ("<h1>C. This is for Coffee</h1>\n");
break;
default:
print ("<h1>D. None of the above</h1>\n");
} // end switch
} // end if (isset(category) )
?>

Archived

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

×
×
  • Create New...