Jump to:

3432 Posts in 1025 Topics by 865 members

Template Questions

SilverStripe Forums » Template Questions » Quick Jump Menu

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

Page: 1
Go to End
Author Topic: 2223 Views
  • filip667
    Avatar
    Community Member
    10 Posts

    Quick Jump Menu Link to this post

    hello , does anyone know how to create the Quick Jump Menu on one particular page?? i'm building the website for the local community centre and they have around 200 groups. rathen then sub-pages i would like to create a "Jump to" menu for each group on the Group page. something similar to this very Forum, where you can select interesting topic (see top right of the page).

    i tried to search for the modules or plugins everywhere but found only extensions for Joomla.

    im a newby, but a big fan of SS already. any help would be appreciated, especially that i hapilly volounteer to help this community centre have its own editable website

    cheers ahead!

  • filip667
    Avatar
    Community Member
    10 Posts

    Re: Quick Jump Menu Link to this post

    this what im looking but for Silverstripe (not Joomla):
    http://extensions.joomla.org/extensions/structure-a-navigation/menu-systems/select-box-menus

    some call it "Quick Jums menu" or "Select Box menu".

    anybody can recommend such module for silverstripe?? i like this CMS so much, that would be a shame to turn to Joomla because of this. i even thought of modifying and adapting the Forum module but my programming skills are not that strong.

    /fil

  • Willr
    Avatar
    Forum Moderator
    5486 Posts

    Re: Quick Jump Menu Link to this post

    No module that I know of provides that but you could write a function to do it. Unlike Joomla you will find in SS you will need to write snippets of code. I recommend reading the tutorials. You may not think yourself as a programmer but for your own sanity it helps to pick up some programming knowledge.

    To write this you would need to get a list of all the pages on the site (I'll omit grouping like this forum for ease). So create a function in your page_controller in Page.php to return all the pages on your site

    function AllPages() {
    return DataObject::get('Page');
    }

    Then in the template you need to build a select and fill it with all pages

    <select onchange="if(this.value) location.href = this.value">
    <% control AllPages %>
    <option value="$Link">$Title</option>
    <% end_control %>
    </select>

    Can put that in any of your templates (eg themes/themename/templates/Page.ss).

  • TotalNet
    Avatar
    Community Member
    181 Posts

    Re: Quick Jump Menu Link to this post

    You don't need a module, you can use the same code principals in your template directly. It's simply a "select" input with an onchange event.

    You can hard-code the links yourself in the template or use a control loop to iterate through the menu links.

    It depends on how these "groups" are going to be represented in the CMS. Are they forums, forum topics or simply child pages of a Groups page?

    Essentially, how do you expect to manage the links? A drop-down box of 200 items is not very usable.

    With a little more detail I can help you out.

    Rich

    EDIT: beat me to it Willr ;)

  • filip667
    Avatar
    Community Member
    10 Posts

    Re: Quick Jump Menu Link to this post

    Gents, both thank you for reply and sorry for delay - almost missed the notification o my thread!

    @Willr - i customised already working code from another website(including the ehader), by changing the <select onchange="if(this.value) location.href = this.value"> as you advised i also changed Page.hph file. i think that <% control AllPages %> causes problems as i get error message: "Parse error: syntax error, unexpected $end in **********.ss.themes.happyorange.templates.Page.ss on line 187".
    before the $Link and $Title attributes worked fine but showed only values of the current page.

    @TotalNet - the groups are simply child pages of the Groups page. i still keep the Side menu and additionally i will need the QuickJump menu. that makes more sense, as there will be over 200 groups, so instead of scrolling all the way down to "Yoga" you can simply click QuickJump menu and press "Y". i hope that explains the idea.

    how can i create the control loop to iterate through the menu links? what's the <select> onchange event value?

    <form name="form" id="form">
    <select name="jumpMenu" size="1" id="jumpMenu">
    <option value="$Link">$Title</option>
    <option value="/**i would like all the child pages here*/">/**Yoga group for example*/</option>
    </select>
    <input type="button" name="go_button" id= "go_button" value="Go" onclick="MM_jumpMenuGo('jumpMenu','parent',0)" />
    </form>

    EDIT:peace&love

    /fil

  • Willr
    Avatar
    Forum Moderator
    5486 Posts

    Re: Quick Jump Menu Link to this post

    @filip667 Yep good fine, my orignal code was missing the <% end_control %> which is required.

  • filip667
    Avatar
    Community Member
    10 Posts

    Re: Quick Jump Menu Link to this post

    cheers @Willr mate, all works fine!! im sure many ss users will benefit from it!

    for those who are interested in the menu with the "GO" button here is the complete code:
    <form class="right" name="form" id="form">
    <select name="jumpMenu" id="jumpMenu">
    <% control AllPages %>
    <option value="$Link">$Title</option>
    <% end_control %>
    </select>
    <input type="button" name="go_button" id= "go_button" value="Go" onclick="MM_jumpMenuGo('jumpMenu','parent',0)" />
    </form>

    it is always set by default to the first child page regardless of where you go - which is a bit annoying. if someone knows how to set as default the Jump to:"Select" field or blank field, please let me know. i guess some kind of <if> loop may be needed within <option value="">Select</option>.
    @TotalNet any advice??

    /fil

    2223 Views
Page: 1
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.