tags:

views:

99

answers:

4

Hi all,

I'm investigating which CMS to use for my next project and am currently looking at Drupal. What I will need to do for the project is create widgets kind of like in Wordpress. Basically, little boxes that the user can provide parameters for, and I use the parameters in the widget. They can then place the widgets on the page, just like blocks. For instance I would like to have a "Double image box" widget. The user would provide text, 2 image urls and a title. The widget would draw the box and wrap the images and text appropriately with divs and styles.

What would the best way to do this in Drupal be?

+1  A: 

Drupal calls these blocks. They work essentially the same way. You create them by having a module hook into hook_block.

ceejayoz
Could I define parameters for the box which the user would have to fill in? I would use those values and wrap them in HTML.
Maria
Yes. That's the 'configure' case in the linked documentation. See the example block module in that documentation for a detailed example (http://api.drupal.org/api/function/block_example_block/6).
ceejayoz
I have created my own module now that lets me take in title, image, text, etc and style it into a block, as I want it to show. But now I'm wondering, can I have multiple instances of a module block, each with different values?
Maria
Not in core. A quick Google did show a module called MultiBlock - http://drupal.org/project/multiblock - that may do what you want.
ceejayoz
A: 

There are lots of modules ready to be used. For some widgets you want to provide it might be possible that a drupal module is already written, so you just need to add it to your installation. I can think of this kind of functionalities right now: http://drupal.org/project/addthis

Ferran Gil
That's not really a widget in the WordPress sense. WordPress widgets are akin to Drupal sidebar blocks.
ceejayoz
I understand. Not that example, but lots of modules provide blocks, so you can show the content there...
Ferran Gil
+1  A: 

For that specific case, I'd suggest creating a new content type using CCK (to give yourself custom fields). The user can use that to add/edit the stuff that goes into the sidebar block.

Then you can use Views to make that content type into a block that you can put into your sidebar block region.

Don't scare this guy off by telling him to create a custom module right off the bat for something that doesn't need it.

Mike Crittenden
A CCK content type is a good idea I hadn't considered. My intent isn't to scare anyone off, I've just been working in Drupal long enough that new modules are old hat.
ceejayoz
Okay then, fair enough :)
Mike Crittenden
Well... Difficult is subjective! I find far much scaring CKK and Views than a module! :)
mac
@mac, the difference is that CCK and Views don't require any coding whereas a custom module requires coding and a basic understanding of Drupal's API.
Mike Crittenden
A: 

i think what you could do best is use the features module. features can carry their own content-types, views, etc. but they are also modules, so you can add your own code, js and css. that way every 'widget' users may want to add can be available through the features interface, and it is kinda easy to deploy. try it out drupal.org/project/features

barraponto