Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Place data from one set of pages on another

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

Page: 1
Go to End
Author Topic: 568 Views
  • DeklinKelly
    Avatar
    Community Member
    196 Posts

    Place data from one set of pages on another Link to this post

    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 {

    }

    ?>

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Place data from one set of pages on another Link to this post

    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

  • DeklinKelly
    Avatar
    Community Member
    196 Posts

    Re: Place data from one set of pages on another Link to this post

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

    568 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.