Jump to:

23482 Posts in 18965 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » [solved] Multiple related pages

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 453 Views
  • theade
    Community Member
    10 Posts

    [solved] Multiple related pages Link to this post

    Hey. I'm looking for a quick pointer. I want a carousel of images on the front page of a site that could contain X items - an image, text link and url for each item. I want the user to be able to customise how many items and add the content for each, from a tab on the front page.

    So at the moment I have a hardwired amount of items in the HomePage class:

          $fields->addFieldToTab('Root.Content.Carousel', new TextField('TitleOne','1. Title'));
          $fields->addFieldToTab("Root.Content.Carousel", new TextField('HoverTextOne', '1. Hover Text'));
          $fields->addFieldToTab('Root.Content.Carousel', new TreeDropdownField("LinkOneID", "1. Link","SiteTree"));
          $fields->addFieldToTab("Root.Content.Carousel", new ImageField('ImageOne', '1. Carousel Image'));

          $fields->addFieldToTab('Root.Content.Carousel', new TextField('TitleTwo','2. Title'));
          $fields->addFieldToTab("Root.Content.Carousel", new TextField('HoverTextTwo', '2. Hover Text'));
          $fields->addFieldToTab('Root.Content.Carousel', new TreeDropdownField("LinkTwoID", "2. Link","SiteTree"));
          $fields->addFieldToTab("Root.Content.Carousel", new ImageField('ImageTwo', '2. Carousel Image'));

    ... etc

    This works OK, but it's ugly and limiting. The ideal solution would be an "add another" button, and a remove button. But I've no idea where to start. Am I missing something fundamental like a nice module or something?


  • martimiz
    Forum Moderator
    1086 Posts

    Re: [solved] Multiple related pages Link to this post

    Hi theade,
    What I would do is create a new DataObject class for the image, url and other properties, then use either a ComplexTableField or DataObjecManager (ss version 2.4) or a GridField (ss version 3.0) on your homepage to add/edit your image objects. This way you can dynamically add as many object as you like.

  • theade
    Community Member
    10 Posts

    Re: [solved] Multiple related pages Link to this post

    Spot on. Thanks for your help. Muchly appreciated.

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.