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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Showing the link from a Sitetree variable in CMS


Go to End


1263 Views

Avatar
fengdeadshot

Community Member, 6 Posts

13 April 2011 at 4:19am

Hey,

Okay, simple question, hopefully simple answer :P

I want to show the URL of my sitetree variable IN the dataobjectmanager, much like the name and description...
However, even if I use 'HomeItemLink.Link' => 'Link' it won't show.
I was wondering if any of you have a solution to this, it's probably something simple that I'm not getting >_<

Example of my HomeItem object code:

<?php
class HomeItem extends DataObject {

	static $db = array(
		'HomeItemTitle' => 'Text',
		'HomeItemDesc'=> 'Text'
	);

	public static $has_one = array(
		'HomeItemImg' => 'Image',
		'HomeItem' => 'Homepage',
		'HomeitemLink' => 'SiteTree'
	);
	
	public function getCMSFields_forPopup() {
		
		 return new FieldSet(
			new TextField('HomeItemTitle'),
			new TextareaField('HomeItemDesc'),
			new SimpleTreeDropdownField('HomeitemLinkID', 'Choose a page to show on the right:', 'SiteTree'),
			new SimpleImageField('HomeItemImg')
		);
		
	}

}

Example of my Page.php code:

$manager = new DataObjectManager(
		$this, // Controller
			'HomeItems', // Source name
			'HomeItem', // Source class
			array(
				'HomeItemTitle' => 'Name', 
				'HomeItemDesc' => 'Desc',
				'HomeItemLink.Link' => 'Link'
			), // Headings 
			'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
			// Filter clause 
			// Sort clause
			// Join clause
		);