Post by idiotao » Thu Jul 29, 2010 1:07 pm

I've been developing a template for my new store and came across one problem. The main navigation on the store is customized and coded into the template (header.tpl) directly, and each link changes background on mouse hover.

Now I would like the link to the "Products" be highlighted when a user is on a product item page or product category page. I've prepared a CSS class for it, but I have no idea how to check whether the current page is a product item/category page or not.

Please help.
Big thanks.

Newbie

Posts

Joined
Thu Jul 29, 2010 1:03 pm

Post by idiotao » Thu Jul 29, 2010 5:35 pm

Never mind that. I've found a solution by using

Code: Select all

$this->request->get['route']

Newbie

Posts

Joined
Thu Jul 29, 2010 1:03 pm

Post by deuce » Fri Jul 30, 2010 4:07 am

For those of you without much PHP knowledge, I took this concept and added something like this to my header.tpl in the theme file.

Code: Select all

<?php 
	$page_route = explode('/',$this->request->get['route']);
	$body_class = '';
	foreach($page_route as $route){
		$body_class .= $route.' ';
	}
	$body_class = substr($body_class,0,-1);
?>

<body class="<?php echo $body_class; ?>">
This will give you something like

Code: Select all

<body class="product category">

when you're on the category page.

New member

Posts

Joined
Sat Jul 03, 2010 1:40 am

Post by dramony » Fri Jul 30, 2010 6:50 pm

Do you have a demo for this?
Thanks!

Active Member

Posts

Joined
Sat Oct 24, 2009 12:34 pm
Who is online

Users browsing this forum: No registered users and 21 guests