0

I use the Sidebar Navigation Menu Professional for Magento by CODNITIVE and I am trying to make it expanded by default. Particularly I need a solution to make just the first list item expanded by default. Here is the code:

<script type="text/javascript" language="javascript">
//<![CDATA[

Codnitive = {

    expandMenu: function(parent) 
    {
        var mode = parent.getElementsByTagName("ul")[0].getAttribute("expanded");
        (mode == 1) ? Codnitive.collapse(parent) : Codnitive.expand(parent);
    },

    expand: function(parent)
    {
        parent.getElementsByTagName("ul")[0].style.display = "block";
        parent.getElementsByTagName("span")[0].style.backgroundPosition = "right center";
        parent.getElementsByTagName("ul")[0].setAttribute("expanded", "1");
    },

    collapse: function(parent)
    {
        parent.getElementsByTagName("ul")[0].style.display = "none";
        parent.getElementsByTagName("span")[0].style.backgroundPosition = "left center";
        parent.getElementsByTagName("ul")[0].setAttribute("expanded", "0");
    }

};



//]]>
</script>

In another forum there was the suggestion to use:

Codnitive.expand(document.getElementById('the-menu-parent-element-id'));

Where exactly should I write this code to make it work? Sorry, but I am not familiar with js.

0

I'd rather edit CODNITIVE's Navigation.php in app/code/community/codnitive/sidenav/block/

on about line 289 there should be

if ($height == 0) {
    $extraStyle = ' display:none;';
}

if you remove display:none it should be visible. You can also add a condition using the $level variable.

Just have a look at the code it's quite straightforward in my opinion.

1
  • Thanks for showing me the file to edit but it doesn't work with display:none. I should edit code if ($config->isCollapsible()) { $width = $config->getCollapsibleIconType() === 'arrow' ? 8 : 16; $height = 0; $expanded = 1 (instead of 0);code But the problem is only partially solved - the "plus" image is still a plus like the menu is still collapsable. I tried to add this condition, but without success - codeif($category->getId()==35): { $expanded = 1; }code
    – capola
    Oct 4 '13 at 14:30
-1

Should add this condition in line 280:

        if ($category->getId() == '35') {
            $expanded = 1;
        }

In this way the category with ID 35 will be expanded by default. There is still another little problem - the "plus" sign remains but it should be "minus" for collapsing the category.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.