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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

VirtualPage?


Go to End


2 Posts   777 Views

Avatar
Wilson

Community Member, 63 Posts

22 November 2010 at 6:41pm

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

Avatar
Wilson

Community Member, 63 Posts

24 November 2010 at 3:07pm

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);
	}

}