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.

Archive /

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

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

Virtual Page to custom page


Reply


2 Posts   3684 Views

Avatar
newjamie

Community Member, 7 Posts

8 February 2008 at 11:32am

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?

Thanks

Avatar
schellmax

Community Member, 126 Posts

24 April 2008 at 10:34pm

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->push($projectPage);         
$children->next();
}      
return $return;   
}

in ProjectHolder.ss:

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

hth