5116 Posts in 1525 Topics by 1118 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 634 Views |
-
$image as link

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
-
Re: $image as link

9 November 2010 at 9:47pm
What you're after is a TreeDropdownField. http://doc.silverstripe.org/treedropdownfield has an example about using it to select a Page.
-
Re: $image as link

11 November 2010 at 3:02pm
Hi,
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
Rob
-
Re: $image as link

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 page.ss
$Podlinkthree.URLSegment
| 634 Views | ||
|
Page:
1
|
Go to Top |

