21487 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 503 Views |
-
Place data from one set of pages on another

13 May 2009 at 8:31am
I want a template named PreviewIndex.ss to place ALL the values from ALL 'PortfolioIdentity' pages on it.
What should I put in PreviewIndex.ss and PreviewIndex.php to get all the data from PortfolioIdentity?
<?php
/// 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 {
}
?>
-
Re: Place data from one set of pages on another

13 May 2009 at 10:23pm Last edited: 13 May 2009 10:24pm
hi hknight
in your PreviewIndex_Controller class you want a function like this:
public function GetPortfolios(){
return DataObject::get("PortfolioIdentity");
}
Then in your PreviewIndex.ss you can do something like this:
<% control GetPortfolios %>
<h2>$ItemTitle</h2>
<p>$ItemSummary</p>
$Icon
<% end_control %>
Hope that helps
-
Re: Place data from one set of pages on another

14 May 2009 at 12:10am
Thanks aram, this is exactly what I needed, and it is so easy to implement!
| 503 Views | ||
|
Page:
1
|
Go to Top |


