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.

Customising the CMS

VirtualPage doesn't pick up custom fields


Reply

2 Posts   1117 Views

Avatar
NickJacobs

6 March 2009 at 4:56pm (Last edited: 6 March 2009 5:01pm), Community Member, 144 Posts

I have a few double-up pages round the site I am working on so thought I had found the answer with the VirtualPage type (keeps the nav & breadcrumb etc intact)....but, I have quite a few different page types in the site and VirtualPage only picks up content and not the custom fields...

Has anyone found a workaround for this. ??

[url=http://ymcagisborne.co.nz/oscar-out-of-school-care-and-recreation]the proper page[/url]
[url=http://ymcagisborne.co.nz/oscar-72]the virtual page[/url] (video content not picked up)

Avatar
Helican

15 April 2009 at 1:17am Community Member, 1 Post

Here's what I'm doing. Seems to work for me.

I have an Event page type, which can have any number of Artist pages as children, but I'm using virtual pages that point to Artist pages rather than actual Artist pages.

So I put this function into EventPage_Controller.

function artistPages() {
   $children = $this->Children();
   $return = new DataObjectSet();
   foreach ($children as $key)
   {
      $virtualPage = DataObject::get_by_id('VirtualPage', $key->ID);
      $artistPage = DataObject::get_by_id('ArtistPage', $virtualPage->CopyContentFromID);
      $return->push($artistPage);
   }
   return $return;
}

and then I put this into EventPage.ss

<% control artistPages %>
$ArtistName
$ArtistDescription
<% end_control %>