How to Disable/Inactivate Some of the Non-Leaf Menu-Items (but keep their children visible and enabled/active)

shayan's picture

shayan
November 22, 2010
6:46am

e.g. in the following menu-item hierarchy, make 'Branch-1' in-sensitive to mouse clicks and/or keyboard operations.

Tree
    Branch-1
        Leaf-1-1
        Leaf-1-2
    Branch-2
        Leaf-2-1
        Leaf-2-2

BTW, the new drop-down menu feature is just FANTASTIC!; (almost as good as the DG's tech-support.)  Thank you.
 

 


 

Status: Resolved

Comments

Moderator
George Cassie November 22, 2010
10:12am

Hi shayan,

There's not yet a way to do this though the site UI, but it could be done with some JavaScript. If you can point me at a sample page and menu item, I can show you how to do it.

George Cassie
Gardens Advisory Team

shayan November 22, 2010
1:24pm

Great! My lucky day today.  Javascript is perfectly fine.

The site is "sana.drupalgardens.com" and two typical cases are:

1) The last item on the top-level menu labeled "Others".

2) The item "Weak" under "Verb" -> "Paradigm".  I mean:

    Verb
        Paradigm
            Weak

I really appreciate your help on this.  Having a working Javascrip sample on a DG site make me feel a lot more confortable for doing other stuff too.

 

Moderator
George Cassie November 22, 2010
2:01pm

Hi shayan,

So, first I set up a text format and a block (called unclickable JS) as described at http://drupalgardens.com/documentation/adding-custom-javascript .

I placed that block into the footer and added this JS:

<script type="text/javascript">
  jQuery(document).ready(function() {
    jQuery('#block-system-main-menu a').filter("[href='/other'],[href='/content/verb-paradigm-weak']").css('cursor','default').click(function(){
      return false;
    });
  });
</script>

George Cassie
Gardens Advisory Team

shayan November 22, 2010
3:08pm

Wow!  Drupal Gardens rocks.

Thanks al lot George for showing me the power of DG. 
I couldn't even imagine embedding and using JS on
Drupal Gardens' pages can be this easy.

Cheers,
Esfand

starryeyez024 March 13, 2011
9:18pm

Hi George, I am trying to do the same thing.

I added the javascript, and I'm trying to make it work on the primary system menu. The problem is in the site above (sana.drupalgardens.com), the menu items are all expanded, where mine are collapsed. They don't get the expanded class until you are on that page. How do I make it so that they are all expanded?

In regular drupal I know this is something you can set in the menu settings (enable /expand) but that function is not visible in DG. Can you help? Here's the site I'm testing it on: http://camplivelaughlove.drupalgardens.com/content/donate

Thanks!!

Moderator
George Cassie March 14, 2011
12:48pm

Hi Kendall,

The expanded menu option should be available, but you need to go into each parent item individually to enable it - it doesn't show up on the menu overview.

If that doesn't help please let me know.

George Cassie
Gardens Advisory Team

shawnpeters March 29, 2011
5:57pm

Hey George,

May I just say that "You are the man!"? Thanks for this post because I'm finishing up a site for a client tonight, and this just saved the day. Normally I would use "Special Menu Items" but since that's not available in DG, hooray JS!

Shawn Peters
Developer, ShawnPetersOnline.com

Moderator
George Cassie March 30, 2011
10:49am

Great, Shawn, glad to hear it!

George Cassie
Gardens Advisory Team

helenajp1978 April 6, 2011
9:21am

Hi George

I'm trying to use the javascript above on my menu - I have the menu item "performance dogwear" but I don't want it to go to a page, ideally when you click or hover over it I wanted it to just expand the children menu items below - I have tried with the javascript above and have edited the menu to show expanded which it is doing but it's expanded all the time. I don't know anything about javascript so completely clueless but have played around with it a bit but doesn't seem to be working so think I am doing something wrong.

Site is scruffimutts.drupalgardens.com

Can you help me?

Cheers

Helena

Moderator
George Cassie April 6, 2011
1:16pm

Hi Helena,

The drop-down menus only work if the block is placed in the Navigation region. If you move it up there, I think the JS will still work.

George Cassie
Gardens Advisory Team

helenajp1978 April 7, 2011
8:06am

Hi George

I have moved the menu to the navigation region and the drop down now works fine but the JS doesn't seem to be working - I have tried to follow your instructions and have created the text format and a new block in the footer first region with the JS above which I've amended for the link I want it to work on like this:-

<script type="text/javascript">
  jQuery(document).ready(function() {
    jQuery('#block-system-main-menu a').filter("[href='/performance-dogwear']").css('cursor','default').click(function(){
      return false;
    });
  });
</script>

Perhaps I've not done it right but it doesn't seem to be working.

What should I try next?

Here is the link to the configure page if that helps

http://scruffimutts.drupalgardens.com/#overlay=admin/structure/block/man...

Thanks alot

Helena

Moderator
George Cassie April 7, 2011
8:35am

Hi Helena,

The /performance-dogwear needed to be changed to /content/performance-dogwear - the JS is selecting the link based on where it goes. I made that change and the menu seems to be working as desired.

Thanks for providing the links in your posts - they help a lot.

George Cassie
Gardens Advisory Team

helenajp1978 April 7, 2011
9:09am

Thank you so much for that - all working great.

Cheers

Helena

lucrozade October 11, 2011
3:54pm

Hi George!

I tried the same, added the script in a block in my copyright region (that is where I have all my blocks with JS) and added the path.

this is the real path: http://usmicroproducts.drupalgardens.com/displays/oleds

This is my code:

<script type="text/javascript">
  jQuery(document).ready(function() {
    jQuery('#block-system-main-menu a').filter("[href='/displays/oleds']").css('cursor','default').click(function(){
      return false;
    });
  });
</script>

 

I am trying to disable the parent link (OLEDs) but still have the hover functioning and whatever I did is not working.

lucrozade October 12, 2011
5:09pm

I guess it is now...

lucrozade October 14, 2011
5:30pm

Hi George,

Is there a way to change the :hover so it doesn't show te text-decoration:underline? I've tried several method but none of them have worked.

Thanks!