Jump to:

10848 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » New Module: Custom Menus

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3 4 5 6 7
Go to End
Author Topic: 7306 Views
  • cumquat
    Avatar
    Community Member
    189 Posts

    Re: New Module: Custom Menus Link to this post

    Hi otherjohn,

    well i normally copy the menu2 control code from the sidebar.ss include on the blackcandy theme then adapt it from there with regards to how i want it to look, see below.

    <ul id="Menu2">
              <% control CustomMenu(main-menu) %>
              <% if Children %>
                  <li class="$LinkingMode"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle.XML</em></span></a>
               <% else %>
                    <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle.XML</em></span></a>
                <% end_if %>   
              
                 <% if LinkOrSection = section %>
                    <% if Children %>
                      <ul class="sub">
                         <li>
                            <ul >
                               <% control Children %>
                                  <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levelb"><span><em>$MenuTitle.XML</em></span></a></li>
                               <% end_control %>
                            </ul>
                         </li>
                      </ul>
                     <% end_if %>
                <% end_if %>
             </li>
             <% end_control %>

    Hope this helps.

    Mick

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: New Module: Custom Menus Link to this post

    That is pretty much how I do it, or, if I am just generating a simple nav with no children:

    <% if CustomMenu(main-menu) %>
    <ul>
    <% control CustomMenu(main-menu) %>
    <li><a href="$Link" class="$LinkingMode">$MenuTitle</a></li>
    <% end_control %>
    </ul>
    <% end_if %>

  • Fouppy
    Avatar
    Community Member
    1 Post

    Re: New Module: Custom Menus Link to this post

    Hi Mo,

    Great module, it does almost exactly what i'm looking for.

    Almost, because i can't get it working correctly with a multilingual site. For example, the site i'm working on has two languages, and i can't select pages which aren't in the default locale.

    Is there any workaround ?

    Cheers

    Fouppy

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: New Module: Custom Menus Link to this post

    Hi Fouppy,

    Unfortunately at the moment multilingual support is limited. I haven't got a huge amount of experience with multilingual sites, so it is tricky coming up with a more supportive version.

    Currently it will only show a regional version of the same page across different language versions of a site. So if you have Home, about and contact in your menu, but under a different language only about has content, only about will appear in the menu.

    I am interested in adding this functionality, so any feature requests or patches give me a shout on this thread, I will look at implementing them!

    Cheers,

    Mo

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: New Module: Custom Menus Link to this post

    Also, this module has now moved to GitHub. URL is:

    https://github.com/mlewis-everley/silverstripe-custommenus

    Please feel free to submit patches, I will try to get on them when I have time .

    Mo

  • juneallison
    Avatar
    Community Member
    108 Posts

    Re: New Module: Custom Menus Link to this post

    Hi Mo - I've installed and set up your module. So far so good! Thank you!

    I had a question about adding to the menu. Basically I will be creating one those "chunky" menus that also displays an image and short description with each menu link. When you hover over the link you see the image and description.

    1. Is there a way to add and manage these content fields within your module?
    2. Do think it would be better to attach these custom fields/data to the actual page (instead of modifying your module)?

    Any input you have would be great. Thank you!

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: New Module: Custom Menus Link to this post

    Hi juneallison,

    You can essentially think of the menu object as a filter. It returns a list of pages to the template, based on which pages you added in the CMS.

    In your template, anything loaded within the custom_menu() control is actually a page object.

    So to do what you want, you would add these items to your page. You could call them something like:

    MenuDescription
    MenuImage

    Then load them inside the loop by using:

    $MenuDescription
    $MenuImage

    Respectively.

    Sound ok?

    Mo

  • juneallison
    Avatar
    Community Member
    108 Posts

    Re: New Module: Custom Menus Link to this post

    Ok, got it. So the data will be attached to the page. That makes sense and I see what you are saying about the menu object being a filter. I wasn't thinking about it that way.

    Thinking out loud... I mentioned the first option thinking it would be nice if there was a central place to modify these images and descriptions. On the other hand that central location would then have to be updated as pages were added or deleted. Attaching the data to the page seems much more concise in terms of coding.

    Thank you for your feedback! I really appreciate it!

    7306 Views
Page: 1 2 3 4 5 6 7
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.