Custom Widget per instance settings

Topics: Writing modules
Oct 2, 2012 at 3:10 PM

Hi was wondering if someone could point me in the right direction.

I'm trying to create a module that contains groups of images. When a widget is added to a page I would like that widget to select the group it wants to show the images for.

I cant' find any examples or documentation.

I can create a module and I'm able to add custom settings to the module but I'm not sure how to associate the instance of the widget part with a specific group in the module settings.

I hope this makes sense.

Cheers

Vinny

Coordinator
Oct 3, 2012 at 1:04 AM

What do you mean by "a specific group in the module settings"?

Oct 3, 2012 at 10:07 AM

I would like to create a image rotator module that takes a groupname as it's setting. That group contains a list of images to use with that instance of the rotator.

So, in my admin for my module I would like to have a section that creates groups and associate images with those groups. (This part I can do).

The next step is to take the widget part, add it to a particular page and associate it with 1 of the groups that was previously created (This part I don't know how to do)

Cheers

Vinny

Coordinator
Oct 3, 2012 at 5:47 PM

So you want to associate a widget with that content item? Well, maybe it's not a widget that you need, but rather you should have a regular part and place that into a different zone?

Oct 4, 2012 at 8:17 AM

I'm pretty new to Orchard module development.

What do you mean by having a regular part and place it in a different Zone ?

How would I do that and how would that solve the 1 group per regular part issue I'm having ?

Is there any examples I can look at I can't find any documentation on this scenario and I'm sure I'm not the only that's wanted to do this.

Thanks for your help so far.

Vinny

Developer
Oct 6, 2012 at 2:53 AM
Edited Oct 6, 2012 at 2:55 AM

Hi Vinny,

You could create a custom part, e.g. "ImageRotatorPart" with a property called "GroupName". Attach that part to the Page content type (or any other content type that you want to add image rotator capabilties to). Your "ImageRotatorPartDriver" emits display shapes, which you can place anywhere yo want (using Placement.info).

Please read the documentation if you're uncertain on how to go about creating custom parts, drivers and widgets. If you have any specific questions on that, please let us know.