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.

Archive /

Our old forums are still available as a read-only archive.

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

parametr pass to <% control %>


Go to End


2 Posts   2370 Views

Avatar
ojalà

Community Member, 87 Posts

12 November 2008 at 12:29am

Hi!
my problem is understand what kind of object pass to <% control %>.
for example I have this: $data = array('Nome' => $data['nome']);
So I can use :
<% if Nome %> and <% control Nome %>
Why?
the same is valid if I use a name of function? can you explain me?I read http://doc.silverstripe.com/doku.php?id=templates&s=renderwith but is not clear

Avatar
Willr

Forum Moderator, 5523 Posts

20 November 2008 at 6:51pm

Edited: 20/11/2008 6:52pm

<% control %> is used to loop over sets of data, or values in 1 DataObject. So any function which returns a 'DataObjectSet' can be used with a control. It is like the foreach() loop in PHP

$data = array('Nome' => $data['nome']); cannot be controlled over as it is only 1 value. So you can check it exists via if Nome. But you would output it in the template as $Nome to get the value