Jump to:

5451 Posts in 1673 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Different Slideshow on every page

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

Page: 1
Go to End
Author Topic: 424 Views
  • carlo
    Avatar
    Community Member
    5 Posts

    Different Slideshow on every page Link to this post

    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?

  • inCharge
    Avatar
    Community Member
    102 Posts

    Re: Different Slideshow on every page Link to this post

    Hi Carlo

    I think you could do this...

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

    424 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.