Change font-weight of current menu item

ssargam's Avatar

ssargam

03 Jan, 2013 09:24 PM

Hi;
I am trying to alter my velocity script, which for now changes font of current active link if the children are selected, but I am not able to bold the current menu item if I go further down, for example:
About Us,is a menu item(directory in cms),it has mission and location pages under it, and About US remains bold if I click on Mission and Locations but a different folder called Services also resides under About Us directory, If I click Services or its children; About US no longer remains bold.

Please find the velocity script attached.

Thank you so much for your help.

  1. 1 Posted by Eric L. Epps on 04 Jan, 2013 02:38 PM

    Eric L. Epps's Avatar

    I believe what you need to do is, instead of checking the "current" attribute, check for whether the full path of the current page contains the path of the $item page.

    I think replacing this line

         #if ($result != '' || $item.getAttribute('current').value == "true")
    

    with

         #if ($result != '' || $currentpath.contains($item.getAttribute('path').value))
    

    will do it, but I haven't tested it.

  2. 2 Posted by ssargam on 04 Jan, 2013 02:56 PM

    ssargam's Avatar

    Thanks Eric. Really appreciate your help.
    This didn't work.

  3. 3 Posted by Eric L. Epps on 04 Jan, 2013 04:19 PM

    Eric L. Epps's Avatar

    Sorry my code didn't work, but the technique should. That's how I do it
    for our left navigation, but I'm using XSL so I don't have the Velocity
    syntax handy.

  4. 4 Posted by ssargam on 04 Jan, 2013 04:40 PM

    ssargam's Avatar

    Thanks again, Eric. I am also new to velocity, so finding it hard to make it work.
    Thanks for your guidance.Really appreciate it.

  5. 5 Posted by Ryan Griffith on 08 Jan, 2013 03:50 PM

    Ryan Griffith's Avatar

    Hi,

    When you have a moment, would you be able to attach the output of your Index Block to help with local testing? If you can, a copy of $contentRoot on your Services page would be ideal. You should be able to do this by placing the following at the top your Format:

    $_SerializerTool.serialize($contentRoot, false)
    

    and copying the XML generating within the page's source code.

    Please let me know if you have any questions.

    Thanks

  6. 6 Posted by ssargam on 08 Jan, 2013 04:03 PM

    ssargam's Avatar

    Hi Ryan;

    Earlier the rendering behavior was: Render normally, starting at the indexed folder
    This was great as rendering time was significantly less but bolding current menu item was an issue as I stated here.
    But now, I changed rendering behavior to: Start at the current page with folder hierarchy, siblings, and also render forward

    this solves my bolding issue but rendering time is a little more( from 9secs to 55secs per page)

    Would your above method have some alternate affect?

    Thanks a lot for your help, really appreciate it.

  7. 7 Posted by Ryan Griffith on 08 Jan, 2013 04:19 PM

    Ryan Griffith's Avatar

    Hi,

    Glad to hear you were able to get things to work. I was curious if there was an issue with your Index Block setup.

    But now, I changed rendering behavior to: Start at the current page with folder hierarchy, siblings, and also render forward... this solves my bolding issue but rendering time is a little more( from 9secs to 55secs per page)

    Are you including page content or any other unnecessary content within your Index Block by chance? This can definitely increase the size of the Index Block and have an affect on the speed of your Format.

    Would your above method have some alternate affect?

    This line is just a way to view and debug the XML that is generated by the Index Block on the calling page, so it would not change the way your Format functions and would be removed when no longer needed.

    Please let me know if you have any questions.

    Thanks!

  8. 8 Posted by ssargam on 08 Jan, 2013 04:30 PM

    ssargam's Avatar

    I see. I don't think there is page content but whenever I get a chance to look at it, I will.

    Thanks again, this gave me a better idea about blocks I'll let you know if I have any additional questions.

  9. 9 Posted by Ryan Griffith on 08 Jan, 2013 04:55 PM

    Ryan Griffith's Avatar

    Definitely take a look at the Render page content options, these are usually the first place to look when trying to optimize Index Blocks.

    Thanks again, this gave me a better idea about blocks I'll let you know if I have any additional questions.

    Glad to hear, if you haven't seen this already, we have some additional information about Index Blocks on our Knowledge Base.

    Have a great day!

  10. Ryan Griffith closed this discussion on 08 Jan, 2013 04:55 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac