Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » GenericViews: $Menu(2) doesn't work in CollectionController.ss

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1318 Views
  • Mat Weir
    Avatar
    Community Member
    33 Posts

    GenericViews: $Menu(2) doesn't work in CollectionController.ss Link to this post

    Hey Ingo,

    I'm having a play with GenericViews and I really like it.

    Having a little trouble with using $Menu(2) in CollectionController.ss (or any other template) when I'm using it as a page in the site tree. After a bit of debugging I found that the 2 isn't being passed to the Menu method but I'm not sure why.

    I'm using trunk version of GenericViews and SS 2.3.3.

    Any ideas?

    Cheers

  • Mat Weir
    Avatar
    Community Member
    33 Posts

    Re: GenericViews: $Menu(2) doesn't work in CollectionController.ss Link to this post

    I've narrowed the problem down to here in CollectionController.php:

       public function __get($field) {
          ...
          } elseif($this->parentController) {
             return $this->parentController->__get($field);
          }
       }

    So it's calling getMenu on the parent controller without passing through any variables from the template.

    I can get around it by adding this to CollectionController.php:

       function Menu($level = 1) {
          return $this->parentController->Menu($level);
       }

    But I wonder if there's a better solution? Otherwise I'll have to do this for every ContentController method that I want to use in the templates...

  • pklopp
    Avatar
    Community Member
    4 Posts

    Re: GenericViews: $Menu(2) doesn't work in CollectionController.ss Link to this post

    I've had similar problems with <% InSection() %> and I've just added the code from the original function which i found via google at svn.silverstripe.com ;)

    I think that would work for you too?

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