633 Posts in 170 Topics by 237 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1414 Views |
-
Submenu in Widget

25 November 2009 at 12:26am
Hi there,
I've been trying to make a submenu widget which shows the children of the current page you're on. However, the menu doesn't show.
This code is in my widget template:
<% if SubNav %>
Test
<ul>
<% control Children %>
<% control Menu(2) %>
<li><a href="$Link">$MenuTitle</a></li>
Test
<% end_control %>
<% end_control %>
</ul>
<% end_if %>The widget consists of two options, which can be en- or disabled via the CMS. The enabling and disabling works, that's why i've got the "Test" line in my code. But the menu doesn't show up. I've tried several combinations of control Children, control Menu() and whatnot, but to no avail.
I've got a hunch that tells me the widget doesn't have "access" to the SiteTree and therefor cannot get the children of the current page, is that correct? If yes, how do i alter that?
Thanks in advance!
-
Re: Submenu in Widget

25 November 2009 at 1:09am
Get rid of the Menu(2) there. <% control Children %> should be all you need.
-
Re: Submenu in Widget

25 November 2009 at 2:26am
Banal, thx for your reply, but that still doesn't work. I've tried every combination of Children and Menu(#), but it doesn't work. I really don't get it why it doesn't...
-
Re: Submenu in Widget

25 November 2009 at 2:41am
Yeah. Somehow you'll have to get the Children of the current page... maybe through a helper method on your widget that grabs it using Director::currentPage() ?
-
Re: Submenu in Widget

25 November 2009 at 3:45am Last edited: 25 November 2009 3:47am
This will most likly not work, but its worth a try, I have not done much with developing widgets.
<% if SubNav %>
Test
<ul>
<% control Parent %>
<% control Children %>
<li><a href="$Link">$MenuTitle</a></li>
Test
<% end_control %>
<% end_control %>
</ul>
<% end_if %>
| 1414 Views | ||
|
Page:
1
|
Go to Top |



