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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

[SOLVED] Page Links in DOM

Go to End

3 Posts   1044 Views


Community Member, 148 Posts

28 July 2009 at 10:23am

Edited: 28/07/2009 11:08am

Hi, I'm trying to output images in a sidebar which link to other pages in the site. I've got it working fine, but just cannot get the page links to output. I'm sure it's something easy I'm overlooking....hopefully someone else can spot it ....


class LinkImageItem extends DataObject
	static $db = array (		
		'Caption' => 'Text'
	static $has_one = array (
		'LinkImage' => 'Image',
		'Page' => 'Page',
		'Link' => 'SiteTree'
	public function getCMSFields_forPopup()
		return new FieldSet(
			new TextField('Caption','Caption'),
			new SimpleTreeDropdownField("LinkID", "Select a page to link to", "SiteTree"),
			new ImageField('LinkImage','Link Image')


class Page extends SiteTree {
	public static $db = array();
	public static $has_one = array();
	public static $has_many = array(	
	'ResourceFile' => 'File',
	'LinkImageItems' => 'LinkImageItem'	
	static $icon = "themes/smartpack/images/treeicons/page";	
	public function getCMSFields()
		$f = parent::getCMSFields();
		$f->addFieldsToTab("Root.Content.ResourceFiles", new AssetManager($this,"ResourceFiles","ResourceFile"));
		// setup the page link images
		$manager = new ImageDataObjectManager(
			$this, // Controller
			'LinkImageItems', // Source name
			'LinkImageItem', // Source class
			'LinkImage', // File name on DataObject
			array('Name' => 'Name'), 
			'getCMSFields_forPopup' );
		return $f;


<% control LinkImageItems %>

<a href="$Link">$Caption</a>

<% end_control %>

Tried all sorts of different ways in the template, but the link never outputs (everything else does)

any ideas??


Forum Moderator, 4102 Posts

28 July 2009 at 10:43am

"Link" is a really bad choice of a fieldname because it is a function on SiteTree objects. But assuming that's not an issue, you have $Link returning a SiteTree object, so the correct code would be $Link.Link


Community Member, 148 Posts

28 July 2009 at 11:07am

Hi, thanks, I've renamed Link to PageLink, and $PageLink.Link works as it should.