Creating a carousel widget and integrating a variable number of widgets/parts into a page

Topics: General
Oct 4, 2012 at 9:53 AM

I would like to know what type of content would you recommend me to create to be able to have a carousel ( I want to build mine not reuse one from the gallery ) that I would be able to incorporate into a  page a variable number of times.

To be more precise I have some pages where I will have a lot of pictures available and will span them across 2 or 3 or more carousels and some where I will have zero or one carousel.

Many thanks

Oct 6, 2012 at 4:47 AM

Create a CarouselWidget content type that has a ProjectionPart attached and a custom CarouselPart. Your carousel part would use the results of the projection part to render each item in the carousel. And because it's a widget, you can add as many as you like to any given page.

Oct 9, 2012 at 10:20 AM

What I don't get is really how create a content type (it will be car for me) that will have a body part for the main content but will allow you to add some pictures to many carousels (many here means that there is a variable number of carousel for each content item of type car). Widget are meant to be visible on all pages (or at least are not contextual to any page/content item seen in particular).

The carousels are really part of my content item.

Oct 9, 2012 at 4:56 PM
Edited Oct 9, 2012 at 4:57 PM

I don't think any of the gallery modules allow for more than one carousel on a given item. You'll probably have to build your own. Or maybe do something not so clean in the body editor where you go into the html and add lists of images with some script to change them into carousels.

Oct 10, 2012 at 2:32 PM
Edited Oct 10, 2012 at 2:55 PM

You could create your content type, attach the usual parts (title, body, autoroute, etc), and attach a projection part as sfmskywalker mentioned. The projection would contain content items that are instances of another content type that you define, your carousel. 

For the carousel you could reuse one of the existing ones from the gallery. I used the "ContentSlider" module and attached it as a part to a few other content types on my site. Each slide of the carousel in this module is just a body part, and you can make it just a picture, or you can put arbitrary html in there. 

Oct 10, 2012 at 2:43 PM

TheMonarch: Will give it a try (I was using Twitter bootstrap one , but I can use ContentSlider too). I ll try my best to follow the best practices so will go for the non lazy solution. 

As a more general question is it possible to attach whatever content part several times to a content item ? It seems from the doc that only one content part can be attached to a content type , but this could be a limition is not it ? What is the workaround ?


Oct 10, 2012 at 4:45 PM

Parts are one per type. Fields can have multiple instances. But I'm wondering, are these going into fixed places or within the body of the item?