-
Pretty simple if you ask me..If you want to assign the same class to every list item, change these lines:
$output .= ‘< li >‘;
to:
$output .= ‘< li class="the-class-name" >‘;and if you want to assign dynamic classes to each of the list items, since each category has its own id, and since we are calling out each id using the $new_path variable, you can integrate the $new_path variable within the $output variable..
Hope that helps :)
-
#3 written by Patrick (2 years ago)
Oh thank you. But I only want to output the class “active” for that li-element which belongs to the current page/category.
For example: If I have a category called “shoes”, I just want to add the class (to that particular li which contents the link to cat. “shoes”) if a page of that category (or subcat.) is displayed.
Goal is to highlight the current/active category in the list-menue.
-
#4 written by Patrick (2 years ago)
Haha, I found the answer here: http://craigmurray.me.uk/opencart-mods/how-to-highlight-the-current-category-in-the-header-in-opencart/
Sorry, but thanks! ;)
-
-
-
#10 written by Tone (2 years ago)
-
-
#16 written by vishu (1 year ago)
sijo thomas:
i’m also getting this Error: Could not load model tool/seo_url!
I’m using Open Cart v1.5.0.5….Any help will be appreciatedwhen i put this code in header.tpl i’m getting this Error: Could not load model tool/seo_url!
I’m using Open Cart v1.5.0.5….Any help will be appreciated…. -
#18 written by Allen Conquest (1 year ago)
Ok, I got it working using a few modification. It’s not doing the SEO rewrites, I’m not sure how to do that at the moment:
//$this->load->model(‘tool/seo_url’);
$this->load->model(‘catalog/category’);$results = $this->model_catalog_category->getCategories(0);
if($results)
{
$output = ”;
}$output .= ‘Home‘;
$counter = 0;
foreach ($results as $result)
{
// HTML
$output .= ”;// Grab the specific category, reset each loop
$new_path = $result['category_id'];// Prepare the URL
$unrewritten = HTTP_SERVER.’index.php?route=product/category&path=’ . $new_path;// Pass it to the SEO URL tool
// $rewritten = $this->model_tool_seo_url->rewrite($unrewritten);// Output the path and category name
$output .= ‘‘ . $result['name'] . ‘‘;$counter++;
// Next level deep with the current category as the parameter.
// Children of
$sub_results = $this->model_catalog_category->getCategories($new_path);// If there are subs
if ($sub_results)
{
// HTML
$output .= ”;
}foreach ($sub_results as $sub_result)
{
// HTML
$output .= ”;// Allocate the new sub category
$new_sub_path = $sub_result['category_id'];// Get the raw URL and prepare it
$sub_unrewritten = $unrewritten.’_’. $new_sub_path;// Rewrite it
// $sub_rewritten = $this->model_tool_seo_url->rewrite($sub_unrewritten);// Output as usual
$output .= ‘‘ . $sub_result['name'] . ‘‘;// Grab the specific category, reset each loop
$new_sub_path = $sub_result['category_id'];// Next level deep with the current category as the parameter.
// Children of
$sub_sub_results = $this->model_catalog_category->getCategories($new_sub_path);// If there are subs
if ($sub_sub_results)
{
// HTML
$output .= ”;
}
else
{
$output .= ”;
}$counter2 = 0;
foreach ($sub_sub_results as $sub_sub_result)
{
// HTML
$output .= ”;// Allocate the new sub category
$new_sub_sub_path = $sub_sub_result['category_id'];// Get the raw URL and prepare it
$sub_sub_unrewritten = $unrewritten.’_’. $new_sub_path.’_’.$new_sub_sub_path;// Rewrite it
// $sub_rewritten = $this->model_tool_seo_url->rewrite($sub_unrewritten);// Rewrite it
// $sub_sub_rewritten = $this->model_tool_seo_url->rewrite($sub_sub_unrewritten);// Output as usual
$output .= ‘‘ . $sub_sub_result['name'] . ‘‘;
$output .= ”;
$counter2++;
}if ($sub_sub_results)
{
// Close off children UL
$output .= ”;
}
$output .= ”;
}if ($sub_results)
{
// Close off children UL
$output .= ”;
}}
if ($results)
{
// Close parent UL
$output .= ”;
}echo $output;
-
#22 written by Martin Vondracek (1 year ago)
-
-
-
#29 written by tarang (1 year ago)
Hi Shahz,
Thanks for replying. Like Wayne above, i also want it on my website and my product upload is pending due to this change..
I have searched opencart forums and php forums..even posted a request to Craig Murray, but m not getting any help :(
Really looking forward for your help…
Thanks in advance..!! -
- Comment Feed for this Post
Building dreams on the Internet Highway







Thanks! I really like your code but would like to add a feature:
I’d like to assign a class to that li-tag which is active.
Like:
Could you help me out?
Best, Patrick