Jump to:

10845 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: 7292 Views
  • Andi
    Avatar
    Community Member
    2 Posts

    Re: New Module: Custom Menus Link to this post

    Mo,
    Maybe i want to ask your help. I've been installed your module to SS 2.3.4. It's work well. The question is, can i modify it to specific ID which is a child from main menu. Example, "A" had some child named "B", "C", "D" so i want to call only for "D" directly. Any solutions??.. T_T

    I'm a newbie here. And need your help to cuztomizing to call it on SS page.

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: New Module: Custom Menus Link to this post

    Hi Andi,

    Do you mean that you want to use the module to create sub navigation? Or make it appear only on certain pages? Or maybe something completely different?

    If its one of the first too, I would sugest adding a variable to your page class, something like:

    'ShowMenu' => 'Boolean'

    Add that to the cms as a CheckboxField and then in your template nest the menu code inside something like:

    <% if ShowMenu %>
    ...
    <% end_if %>

    Mo

  • Andi
    Avatar
    Community Member
    2 Posts

    Re: New Module: Custom Menus Link to this post

    This is the case details. I have a photo in my HomePage.ss. I want to insert the link in the image, which will go directly to the child page that is in the main menu.

  • muktibowo
    Avatar
    Community Member
    2 Posts

    Re: New Module: Custom Menus Link to this post

    hmmm... ic ...

    I assumed that you want to display the last child page from the Main Menu let you insert the following code:

    <% control CustomMenu(SLUG) %>

    <% if Last %>

    ....
    <a href="$Link"><img border="0" src="your photo URL"></a>
    ....

    <% end_if %>

    <% end_control %>

    Post back if it works!!... ^_^

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: New Module: Custom Menus Link to this post

    Or if you want it to appear next to the Homepage link, and the image has been attached via the CMS, you could do something like:

    ...
    <% if HomePagImage %>
    <li><a href="$Link">$HomePageImage $Title</a></li>
    <% end_if %>
    ...

    Cheers,

    Mo

  • dvdsetshop
    Avatar
    Community Member
    8 Posts

    Re: New Module: Custom Menus Link to this post

    Brilliant, crossing fingers must have worked!

    -----------------------------------------------------------------------------------------------------
    www.dvdsetshop.com

  • plungerman
    Avatar
    Community Member
    2 Posts

    Re: New Module: Custom Menus Link to this post

    can anyone suggest a way that i might be able to pass a variable to the custom menu handler? that is, instead of passing in a menu slug, you would pass in the URLSegment:

    <% control CustomMenu(URLSegment) %>

    that way, you can give the custom menu slug the same value as the page slug and display a menu automatically, if said menu exists. if not, display a default menu.

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: New Module: Custom Menus Link to this post

    Hmm, At the moment this would be a little tricky. The best way I can think of it would be to add a $has_one to your Page class, something like:

    $has_one = array(
    'CustomMenuLink' = 'CustomMenu'
    );

    Then you would add a Dropdown field (or something like that) to the CMS and have a custom method on your page controller, something like:

    public function loadMenu() {
    return DataObject::get_by_id('CustomMenu',$this->CustomMenuLink()->ID);
    }

    Then you could add this in your template:

    <ul>
    <% control loadMenu %>
    <li>$Title</li>
    <% end_control %>
    </ul>

    Just a couple of disclaimers:

    1. This isn't tested, you will probably have to tweek it to get it working.

    2. This should work in 2.4 with a little modification, but I am not sure about 2.3 (or lower).

    Hope that helps,

    Mo

    7292 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.