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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Nested Controllers


Go to End


3 Posts   1958 Views

Avatar
Brig

Community Member, 26 Posts

8 August 2009 at 12:31am

Hello

I'm in need of some help please. I'm trying to nest two controllers but cannot get it to work.

Here's my code:

<% control Members %>
<div id="$Name" style="display: none;">
<table class="rostertable" cellpadding="0" cellspacing="0">
<tr class="rostertr">
<td class="rostertdleft" colspan="3"><strong>$Name's Alts</strong></td>
</tr>
<% control Alts %>
<tr class="rostertr">
<td class="rostername">$Name</td>
<td class="rosterlvl">$Level</td>
<td class="rosterlvl"><img style="border: none;" src="/themes/newdawn/images/magelo.png" alt="Magelo" /></td>
</tr>
<% end_control %>
</table>
</div>
<% end_control %>

When I try this it just ignores the Alts controller. Both controllers are MySQL calls which I've created in my PHP page.

This is the kind of output I'm after:

<div id="BexieAlt" style="display: none;"> 
<table class="rostertable" cellpadding="0" cellspacing="0"> 
<tr class="rostertr"> 
<td class="rostertdleft" colspan="3"><strong>BexieAlt's Alts</strong></td> 
</tr> 
<tr class="rostertr"> 
<td class="rostername">BexieAlt</td> 
<td class="rosterlvl">78</td> 
<td class="rosterlvl"><img style="border: none;" src="/themes/newdawn/images/magelo.png" alt="Magelo" /></td> 
</tr>
<tr class="rostertr"> 
<td class="rostername">BexieAlt2</td> 
<td class="rosterlvl">78</td> 
<td class="rosterlvl"><img style="border: none;" src="/themes/newdawn/images/magelo.png" alt="Magelo" /></td> 
</tr>
...
...
...
</table> 
</div>

Could someone be so kind and offer me some hints to how I can solve this please? It's the final bit of a quite large website project so I'm very eager to get it working!

Avatar
robinp

Community Member, 33 Posts

8 August 2009 at 6:07pm

Hi,

This does partly depend I how you have got your dataobjects set up but I have feeling instead of

<% control Alts %> 

You need

<% control Top.Alts %> 

Does that work for you ?

Cheers

Robin

Avatar
Brig

Community Member, 26 Posts

10 August 2009 at 6:39am

Wow that worked! Thanks so much for the help!