Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8641951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:39:36+00:00 2026-06-12T11:39:36+00:00

With the code blow I retrieve the current parent category and his children. Is

  • 0

With the code blow I retrieve the current parent category and his children. Is it possible to add an active class for the current child?

<?php
$currentCat = Mage::registry('current_category');
if ( $currentCat->getParentId() == Mage::app()->getStore()->getRootCategoryId() )
    {
    $loadCategory = $currentCat;
    }
    else
    {
    $loadCategory = Mage::getModel('catalog/category')->load($currentCat->getParentId());
    }
    $subCategories = explode(',', $loadCategory->getChildren());
    foreach ( $subCategories as $subCategoryId )
    {
    $cat = Mage::getModel('catalog/category')->load($subCategoryId);
    if($cat->getIsActive())
        {
        echo '<li><a href="'.$cat->getURL().'">'.$cat->getName().'</a></li>';
        }
     }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:39:38+00:00Added an answer on June 12, 2026 at 11:39 am

    You already have the current category, so you can check it’s ID against the IDs of the categories being looped through.

    Where you have

    echo '<li><a href="'.$cat->getURL().'">'.$cat->getName().'</a></li>';
    

    Change it to do the check for the ID and then add the “active” class when found

    $class = '';
    if ($currentCat->getId() == $cat->getId())
    {
        $class = ' class="active"';
    }
    echo '<li'.$class.'><a href="'.$cat->getURL().'">'.$cat->getName().'</a></li>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i saw a example for login form same blow code class Form_Login extends Zend_Form
Possible Duplicate: Initializer syntax Short code sample to demonstrate (VS2010 SP1, 64-bit Win7): class
I am using blow code for join in nhibernate, which is working fine. But
Code: <?php //initializing script, do not modify session_start(); define('IN_SCRIPT', true); //so that global.php cannot
the blow code work fine on IE, but doesn't work on firefox, why? It's
The code blow was used for authenticatin for a page (it is snippet of
I have the code blow for tabbing through 2 fields and it has no
I have the following code which seems to blow up if the column in
I use code blow to replace \\ with \ NSString *str =@\\u597d\\u6f02\\u4eae\\u7684\\u5a5a; str= [str
I've created this code blow that works and does what I want it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.