21311 Posts in 5739 Topics by 2604 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 226 Views |
-
[solved] Multiple related pages

25 September 2012 at 5:20pm
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
-
Re: [solved] Multiple related pages

25 September 2012 at 10:57pm
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. -
Re: [solved] Multiple related pages

26 September 2012 at 11:50am
Spot on. Thanks for your help. Muchly appreciated.
| 226 Views | ||
|
Page:
1
|
Go to Top |

