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.

Customising the CMS /

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

Different Slideshow on every page


Go to End


2 Posts   1628 Views

Avatar
carlo

Community Member, 6 Posts

31 March 2012 at 4:15am

Hey,

I'm very new to SilverStripe, so sorry for this newbie post and my bad english. I'm using SilverStripe for one month and I'm lovin it :) For my actual project I integrated already my own template, my own gallery extension (with help of some forum posts and this great DataObjectManager).

Now I will create a new CMS-DropDown-Field for every page, where you can change the slideshow. My idea was:

I have slideshow images in 3 different HTMLs as .ss files in "themes/mylayout/templates/Insludes/" (officeSlideshows.ss …). I have written following to my mysite/code/Page.php:


…
public static $db = array(
		// Change Slideshow - Dropdownfields
		'SliderDesign' => "Enum('officeSlideshow, productSlideshow, otherSlideshow')"
	);

	// Choose Slideshow as default
	public static $defaults = array(
		'SliderDesign' => 'officeSlideshow'
	);
	
	// Add a Dropdownfield to CMS
	public function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab("Root.Content.Main", new DropdownField('SliderDesign', 'Choose your header slideshow', singleton('Page')->dbObject('SliderDesign')->enumValues()), 'Content');
		return $fields;
	}
…

Now I can see this drop down field in my backend and I can change the value, yeah :)
And now? I thought, I could add following to my theme (Page.ss):


…
<div id="topslider">
	<% include $SliderDesign %>
</div>
…

… and it would change to one of my variable values (e.g. officeSlideshow) and insert the content of officeSlideshow.ss (from includes/), but it doesn't! -.-

What I'm doing wrong?
Or is there a better way to change Layoutparts (like different slideshows) in the Backend of SilverStripe?

Avatar
inCharge

Community Member, 102 Posts

12 April 2012 at 1:04am

Hi Carlo

I think you could do this...

<% if SliderDesign  = officeSlideshow %>
   <% include officeSlideshow %>
<% else_if SliderDesign  = productSlideshow %>
   <% include productSlideshow %>
<% else_if ...etc