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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

$image as link

Go to End

4 Posts   1163 Views


Community Member, 5 Posts

9 November 2010 at 7:47pm

I would like to do the following with the CMS so that I can pick am images from the files area and then also select a link of a page for it to go to.

<% if Image%>
<p><a href="$ImageLink">$Image.SetWidth(222)</a></p>
<% end_if %>

I have figured out the Image part but what I need to do is to setup a drop down in the backend to select a page from the CMS

If anyone is able to help that would be good.

Thank you


Community Member, 473 Posts

9 November 2010 at 9:47pm

What you're after is a TreeDropdownField. has an example about using it to select a Page.


Community Member, 5 Posts

11 November 2010 at 3:02pm


Thank you for the link. I have tried a few different options to get this working and cannot figure this out. I am not really a developer so there is a little more guess to this. This is what I have now the problem is I cannot figure out how to make this appear in the backend so i can select a page:

   static $has_one = array(
  'Banner' => 'Image',
  'Podone' => 'Image',
  'Podtwo' => 'Image',
  'Podthree' => 'Image',
  'RightContent' => 'SiteTree'

   function getCMSFields() {
      $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.Content.Banner", new ImageField('Banner'));
     $fields->addFieldToTab("Root.Content.Pods", new ImageField('Podone'));
     $fields->addFieldToTab("Root.Content.Pods", new ImageField('Podtwo'));
     $fields->addFieldToTab("Root.Content.Pods", new ImageField('Podthree'));
	$treedropdownfield = new TreeDropdownField("RightContentID", "Choose a page to show on the right:", "SiteTree");

      return $fields;

I tired a few different things but nothing worked.

Thank you in advance



Community Member, 5 Posts

14 November 2010 at 1:00pm

I ended up using this

$fields->addFieldToTab("Root.Content.Pods", new TreeDropdownField('PodlinkoneID', 'Select the page...', 'SiteTree'));

I got a few errors but this was because I needed to add .URLSegment in the