21288 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 317 Views |
-
Iterate through $has_many items

12 February 2012 at 3:54am Last edited: 12 February 2012 3:55am
Just wanted to confirm,
There isn't (currently?) a way to access every item of a 'normal' SS data type (image, text, etc) I've got in a $has_many in my page? Like I would with a <% control %>?
(I have a bunch of images I want to access but don't really feel like I should have to create a new object just to fill it with a single piece of data...)
I've seen this http://www.silverstripe.org/archive/show/408 but it is quite old, might not be exactly the same as what I want and maybe something's changed!
Just want to find the simplest solution to what I think must be a simple problem!
-
Re: Iterate through $has_many items

12 February 2012 at 8:29pm Last edited: 29 March 2012 8:30pm
You can use a <% control %> statement (or <% loop %> in SS3.0) to iterate over a has_many. Has_many relationships are ComponentSets.
http://api.silverstripe.org/2.4/sapphire/model/ComponentSet.html
| 317 Views | ||
|
Page:
1
|
Go to Top |


