3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 941 Views |
-
<% control Children %> and Object->Children() only return when shown in Menu?

22 October 2009 at 5:31am
Hi,
I'm working on some code to generate a Tab Container with Tabs (which will then be rendered using jQuery). because this will be Tab content, it should not show in Menu and Search and so on so I switched this off in the defaults for those page types (TabContainer and TabContent).
Now I went to work on the coding and found that my tabs (as children of the tabscontainer) did not show up if I did a <% control Children %> in the TabsContainer template or in the controller for that page (as object->Children())... I found this was due because in the CMS, the tickbox 'Show In Menu' was off... Seemed very weird to me and took me ages to find out...
Is this by design? And if yes - WHY? It would make sense to exclude those pages that are set not to show in menu if you <% control Menu %> but it seems, they completely dissapear from the parent object..
The only way to get to these children was by accessing the dataobject on the controller of the TabsContainer:
public function getTabs(){
return DataObject::get("TabContent", "ParentID = $this->ID");
}
It works - but still - this seems really counterintuitive and not very MVC to me..
-
Re: <% control Children %> and Object->Children() only return when shown in Menu?

22 October 2009 at 11:45am
Hi!
Try AllChildren.
-
Re: <% control Children %> and Object->Children() only return when shown in Menu?

22 October 2009 at 4:54pm
+1 what Junaitou said.
<% control Children %> returns a set that is filtered through canView() on each page. <% control AllChildren %> will return the children, disregarding canView().
-
Re: <% control Children %> and Object->Children() only return when shown in Menu?

22 October 2009 at 10:34pm
Ah - that makes more sense ;-) Thanks!
Unfortunately, I'm getting a 'White Screen Of Death' if I use AllChildren - I'll investigate a bit more...
-
Re: <% control Children %> and Object->Children() only return when shown in Menu?

22 October 2009 at 10:45pm Last edited: 22 October 2009 10:45pm
I must have made a Typo when I tried AllChildren yesterday, as it does seem to work now..
Brilliant - thanks!
| 941 Views | ||
|
Page:
1
|
Go to Top |


