Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » How to make top menu sections without content and jump to the first child?

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 3596 Views
  • Liam
    Avatar
    Community Member
    470 Posts

    Re: How to make top menu sections without content and jump to the first child? Link to this post

    I'd like the same type of thing, except I don't need a link outputted from a certain parent page. I need just a blank <a> tag produced from a page in the sitetree, no redirects.

    The reason being I am building a suckerfish navigation menu so I still need the <a> tag produced for the parent, so when a user hovers over it, the suckerfish menu is displayed listing the child pages.

    Is this at all possible?

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: How to make top menu sections without content and jump to the first child? Link to this post

    Hmm, one way I think you could achieve this would be to override the Link() method on your page-type. This means that for that particular $Link in the template loop for the menu there's nothing returned, thus you can do <% if Link %><a href="$Link">$MenuTitle</a><% else %><span>$MenuTitle</span><% end_if %> - or something similar.

    Example:

    <?php

    class UnlinkedPage extends Page {

       function Link() {
          return false;
       }

    }

    class UnlinkedPage_Controller extends Page_Controller {

    }

    ?>

    It's kind of a theory more than anything. I'm not sure if there'll be any side effects from a page not having a valid Link() method, but it's certainly worth a try I believe.

    Sean

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