Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » VirtualPage?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 474 Views
  • Wilson
    Avatar
    Community Member
    63 Posts

    VirtualPage? Link to this post

    Hi everyone,

    I'm sure this isn't the first time this has been asked, but I haven't been able to locate the answer.

    If I create a VirtualPage link to a page that uses DOM, the DOM objects from the 'real' page aren't inherited.. Is that expected behavior? I found a few hacks for individual cases, but I'm curious if either I'm doing something incorrectly or there's a known way to create this dependence.

    I've already built the back-end nav structure, so would be nice if there were!

    Thanks in advance, for your time!
    Wilson

  • Wilson
    Avatar
    Community Member
    63 Posts

    Re: VirtualPage? Link to this post

    Solved, thanks to Zauberfisch.

    class VirtualPageWithImages extends VirtualPage {
       
       static $icon = array("cms/images/treeicons/page-shortcut-gold","file");   

       public function getCMSFields() {
          $f = parent::getCMSFields();
          $f->removeByName('Photos');
          return $f;
       }
    }

    class VirtualPageWithImages_Controller extends VirtualPage_Controller {

       public function Photos() {
          return DataObject::get('Photo', 'PageID = '.$this->CopyContentFrom()->ID);
       }

    }

    474 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.