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

  • Home
  • SEARCH
  • 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 8509561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:28:04+00:00 2026-06-11T03:28:04+00:00

Excuse me for asking such a general question. I’m creating a website with Orchard

  • 0

Excuse me for asking such a general question. I’m creating a website with Orchard CMS. The website’s design and interactivity are critical requirements. I have a navigation menu which has a fixed size(900 px wide), but should be able to adjust as many menu items as possible (I do this manually by modifying the css). I’ve used a bit of jQuery to create some animations on mouse hovers etc. for the menu. Problem is that the css and jQuery parameters are hard coded. So if a user were to change to add a new menu item, they need to know in advance the number of menu items, and sub items, thus it’s not very easy for the average user to customize it which the whole point of a CMS. What is the best way of keeping this menu interactive (with the jQuery animations), and such that the user can be able to add content pages to this menu (as they do with the default navigation menu in orchard) and also user friendly such that the non technical user need to have to mess around with the jQuery and CSS of the menu?

What is the best way of doing this, should I create a module (a navigation menu component?) which will dynamically set the css/jQuery values (width etc.)

UPDATE
Also, right now I have my HTML (my navigation menu, Unorderd List etc.) and its jQuery script reference embedded in my Layout.cshtml, and the style for the navigation menu is in my Site.css in my theme, is this considered bad practice?

  • 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-11T03:28:05+00:00Added an answer on June 11, 2026 at 3:28 am

    I eventually got this done in orchard 1.5 by overriding the Menu.cshtml view, coding some logic to check the number of menu items and then rendering navigation menus with different ID’s, based on the number of menu items they contained. I then added different CSS selectors in my Site.css, each with CSS suitable for navigation menus of various sizes. Here is what my Menu.cshtml ended up looking like (this goes in the Views folder of your currently active theme).

    @
    {
    
        Script.Require("jQuery");
        var tag = Tag(Model , "ul");
        var items = (IList<dynamic>)Enumerable.Cast<dynamic>(Model.Items);
    
    }
    @{//if the menu contains 3 items, render a nav called 'ThreeItemNav'
    if(items.Count == 3){
    <nav id="ThreeItemNav">
        @tag.StartElement
            @* see MenuItem shape template *@
            @DisplayChildren(Model)
        @tag.EndElement
    </nav>
    }
    else if(items.Count == 4){
    <nav id="FourItemNav">
        @tag.StartElement
            @* see MenuItem shape template *@
            @DisplayChildren(Model)
        @tag.EndElement
    </nav>
    
    }
    else if(items.Count == 5){
    <nav id="FiveItemNav">
        @tag.StartElement
            @* see MenuItem shape template *@
            @DisplayChildren(Model)
        @tag.EndElement
    </nav>
    
    
    }
    }
    
    //Include the jQuery to add animations to the navigation menu
    @using (Script.Foot())
    {
        <script type ="text/javascript">
        //<![CDATA[
            $(document).ready(function () {
           //Add your script here
                $(" #FiveItemNav li").hover(function () {
            //Do something when the sub menu list items are hovered....
                });
    
    
                $(" #FourItemNav li").hover(function () {
            //Do something when the sub menu list items are hovered....
                });
    
                $(" #ThreeItemNav li").hover(function () {
            //Do something when the sub menu list items are hovered....
                });
            });
    
    
        //]]>
        </script>
    }
    

    Note that you need to add CSS selectors in your theme for each nav element (ThreeItemNav, FourItemNav and FiveItemNav), for example in your current themes Site.css:

    /*Style the Three Item Navigation menu*/
    #ThreeItemNav li
    {    
    background-color:#263A79;
    }
    
    #ThreeItemNav a:hover
    {
    border-right:1px solid #333;
    border-left:1px solid #333;
    }
    
    
    #ThreeItemNav > ul li.current 
    {
           background:#5882FA;
    }
    
    /*Style the Four Item Navigation menu*/
    
    #FourItemNav li
    {
           background:#Purple;
    }
    
    #FourItemNav a:hover
    {
           background:Orange;
    }
    
    .........more styles
    

    This certainly seems like a long winded approach, but it’s the best I could think off so that I can maintain the functionality of the Orchard navigation menu and still style it with CSS and add jQuery animations. I figured an initial development cost was worth adding some powerful capabilities to the navigation menu in the long run. I’d love to hear any suggestions on how to do this in a neater way. Also I would definitely recommend using Orchard 1.5, since it has built in support for creating hierarchical navigation menus.

    Checking out the inner workings of Menu.cshtml and MenuItem.cshtml views help a lot in trying to understand how the navigation menus are rendered in Orchard as well as inspecting how the default Theme Machine styles the navigation menu and its various levels/sub menus.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a newbie in jQuery, so excuse me for asking such a simple question.
Excuse the n00bness of this question, but I have a web application where I
Excuse the terrible question title. I have this PHP string and want to check
Excuse my lack of knowledge. Im creating a a php/mysql website which will store
I feel foolish asking such a fundamental question but it would be more foolish
Excuse the extremely newbie question... Once I have verified the users login credentials, Where
I'm new to programming for iOS and on MacOs, so excuse me for asking
Excuse the simple question, the issue i'm having maybe due to lack of sleep.
Excuse the 'noob' question, but can someone please explain the way ASP.NET's buttons work.
Excuse if this is more a file format conversion question rather than programming, but

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.