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

[solved] access has_many from template


Go to End


2 Posts   2308 Views

Avatar
madmaurice

Community Member, 20 Posts

30 November 2009 at 12:57am

Edited: 30/11/2009 2:34am

Im about to create a selfmade image gallery. i created a datamodel named GalleryImage.
and added a "Title" to the static $db.

I created a GalleryPage page type and added

static $has_many = array("Images"=>"GalleryImage");

to it.
Then i ran /dev/build?flush=1
and altough ive added some GalleryImages to it and inserted

<% control Images %>
$Title <br>
<% end_control %>

inside my GalleryPage.ss file no Title of the Images shows.

edit:

GalleryPage.php : http://pastie.org/719094
GalleryPage.ss : http://pastie.org/719095
GalleryImage.php : http://pastie.org/719098

Avatar
madmaurice

Community Member, 20 Posts

30 November 2009 at 2:33am

Damn it. got it...

Forgot to check the checkbox left of the entry in the admin panel.....

shame on me...