Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

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

GenericViews: $Menu(2) doesn't work in CollectionController.ss


Reply


3 Posts   1345 Views

Avatar
Mat Weir

Community Member, 33 Posts

14 October 2009 at 10:46am

Edited: 14/10/2009 10:47am

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

Avatar
Mat Weir

Community Member, 33 Posts

15 October 2009 at 10:34am

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

Avatar
pklopp

Community Member, 4 Posts

26 March 2010 at 10:58pm

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?