Jump to:

23367 Posts in 18143 Topics by 2863 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: 429 Views
  • theade
    Avatar
    Community Member
    9 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?

    Thanks

  • martimiz
    Avatar
    Forum Moderator
    1067 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
    Avatar
    Community Member
    9 Posts

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

    Spot on. Thanks for your help. Muchly appreciated.

    429 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.