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

Show limit object on Page


Go to End


933 Views

Avatar
bubu333

Community Member, 8 Posts

23 November 2012 at 10:12pm

I have a HolderPage.php and I create children page for HolderPage.php(ProjectPage.php)
When i show on template i write:
<% control Children %>
<h2>$Title</h2>

<% end_control %>

And i create ImageObject.php:
static $has_one=array('ProjectPage'=>'ProjectPage');
ProjectPage.php:static $has_many=array('ImageObjects'=>'ImageObject');
I show imageobject.php on template
<% control Children %>
<h2>$Title</h2>
<% control ImageObjects %>
$Photo
<% end_control %>
<% end_control %>

It work fine but i want to show 3 image on template,If user create 5 image i just want to show 3.
And i don't know where i can write function that...I tried to write it in HolderPage_Controller,ProjectPage_Controlller...It not work.Help me!