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

<% control something %> and output "this" inside of the control


Go to End


3 Posts   1859 Views

Avatar
spierala

Community Member, 80 Posts

24 March 2010 at 1:27am

Edited: 24/03/2010 3:17am

Hello all,

i have a control in a template like this:

<% control Images %>

<% end_control %>

the control iterates a list of images. each object is type of Image (standard silverstripe class)
actually i would like to output the image like this inside the control

<% control Images %>
$Image
<% end_control %>

of course this is not working because I think I can only access properties of an object inside of a control. Image is not property of image. but can I somehow output the object itself? by using something like $this ...? i need it to say $this.SetWidth(100)

thanks in advance,
florian

Avatar
Willr

Forum Moderator, 5523 Posts

24 March 2010 at 9:30am

If you are inside that control, and each item is an image object then you don't need this. You can just do $SetWidth(100)

Avatar
spierala

Community Member, 80 Posts

25 March 2010 at 9:58pm

thanx Willr!
worked fine.