Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Virtual Page to custom page

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 3596 Views
  • newjamie
    Community Member
    7 Posts

    Virtual Page to custom page Link to this post

    I have a page that has various additional fields set in addition to the main "Content" one. Also, it uses a different template.

    How can I get my VirtualPage to use a different template from the standard Page.ss (shouldn't it grab the template from the target page anyway?) and use the additional fields?


  • schellmax
    Community Member
    126 Posts

    Re: Virtual Page to custom page Link to this post

    had the same problem, couldn't find a function for this so here is my workaround:

    say 'ProjectHolder' has 'VirtualPage' children pointing to some 'ProjectPage'. every 'ProjectPage' has a field 'Date', aside from the content, i want to show on my 'ProjectHolder' page:

    in ProjectHolder_Controller:

    function projectPages() {
    $children = $this->Children();
    $return = new DataObjectSet();
    for ($i = 0; $i < $children->TotalItems(); $i++) {
    $virtualPage = DataObject::get_by_id("VirtualPage", $children->Current()->ID);
    $projectPage = DataObject::get_by_id("ProjectPage", $virtualPage->CopyContentFromID);
    return $return;   

    in ProjectHolder.ss:

    <% control projectPages %>
    Project Date: $Date
    Project Content: $Content
    <% end_control %>


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.