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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Place data from one set of pages on another


3 Posts   605 Views


13 May 2009 at 8:31am Community Member, 197 Posts

I want a template named to place ALL the values from ALL 'PortfolioIdentity' pages on it.

What should I put in and PreviewIndex.php to get all the data from PortfolioIdentity?


/// PortfolioIdentity.php
class PortfolioIdentity extends Page {

static $db = array(

'ItemTitle' => 'Text',
'ItemSummary' => 'Text'

static $has_one = array(

'Icon' => 'Image'


function getCMSFields() {

$fields = parent::getCMSFields();

$fields->addFieldToTab("Root.Content.PortfolioIndex", new ImageField('Icon','Item Icon'));

$fields->addFieldToTab("Root.Content.PortfolioIndex", new TextField('ItemTitle','Item Title'));

$fields->addFieldToTab("Root.Content.PortfolioIndex", new TextField('ItemSummary','Item Summary'));

return $fields;



class PortfolioIdentity_Controller extends Page_Controller {



Carbon Crayon

13 May 2009 at 10:23pm (Last edited: 13 May 2009 10:24pm), Community Member, 598 Posts

hi hknight

in your PreviewIndex_Controller class you want a function like this:

public function GetPortfolios(){

return DataObject::get("PortfolioIdentity");


Then in your you can do something like this:

<% control GetPortfolios %>
<% end_control %>

Hope that helps :)


14 May 2009 at 12:10am Community Member, 197 Posts

Thanks aram, this is exactly what I needed, and it is so easy to implement!