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.

Template Questions /

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

Nested Controls


Go to End


2 Posts   2030 Views

Avatar
Aperage

Community Member, 6 Posts

17 December 2009 at 8:30am

Edited: 17/12/2009 8:38am

Hey hey,

Is it possible to have nested control?

I have this code here

<% control getSpeciesType %>
        <h2>$Type</h2>
        <div class="species">
            <% control ShowSpeciesByType %>
                <h3>$Title</h3>
                <p>$Description</p>               
            <% end_control %>
        </div>
<% end_control %>

Both custom functions returns a DataObjectSet. But i've tried debugging by putting an exit(); in my nested function (ShowSpeciesByType) but the script doesn't even get there

So is it possible to have nested Controls??

Thanks
Aperage

Avatar
Willr

Forum Moderator, 5523 Posts

17 December 2009 at 8:57am

Yes you can have nested controls but once your in the getSpeciesType control then the scope of the template changes to the SpeciesType object so whatever control you want in that - eg ShowSpeciesByType needs to be a function in the SpeciesType class.