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 ....
LinkImageItem.php
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')
);
}
}
Page.php
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' );
$f->addFieldToTab("Root.Content.LinkItems",$manager);
return $f;
}
}
In Page.ss
<% control LinkImageItems %>
$LinkImage
<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??