Integrate with CTools for AJAX and plugins

merlinofchaos - October 27, 2009 - 04:05
Project:Vote Up/Down
Version:6.x-2.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:active
Description

I took a look at this as something I want to use in a site I'm building, primarily as an example. I thought the implementation of widgets fell short -- do you really want people modifying your module's directory to add their widgets? That kind of sucks.

CTools provides a great plugin system to allow modules and themes to provide widgets. This means themes can SHIP with customized vote up/down widgets that fit for that theme and are simply selectable.

Also, CTools has an AJAX framework that made it possible to remove all javascript from this package. Makes widget creation easier when you don't have to worry about javascript at all. To facilitate this I moved the javascript response callback to the .theme.inc file, and modified the call slightly since these calls now need to know which widget is in use so it knows how to render the result.

Finally, this corrects a couple of errors in the template file, such as not using t(). And I included documentation on the widgets.

Whether this patch is accepted or not, I'll be building a site with a module that utilizes this patch. I may release a vote_up_down submodule for another voting type, but won't be able to release it without this patch. However you want to do it.

#1

merlinofchaos - October 27, 2009 - 04:06

Note that this adds a .inc file for each widget and removes the .js file for each widget, so be sure to cvs add and cvs rm accordingly. patch won't do that part for you.

#2

merlinofchaos - October 27, 2009 - 04:23

Oh and yes, I realize this adds a dependency on another module. However:

1) CTools will spread
2) The AJAX framework in CTools is pretty close to what went into core for Drupal 7, so it's more in line with what you'll want for D7 updating anyway.

#3

merlinofchaos - November 3, 2009 - 15:29

Weird. I remember there being a patch here once. Ah well. Here is the patch.

AttachmentSize
ctools-plugin.patch 35.88 KB

#4

MichaelP - November 5, 2009 - 12:18

Merlin,

could you elaborate on the installation steps of this patch for lesser mortals please?

Many thanks.

#5

nightowl77 - November 16, 2009 - 08:24

For people reading the issue thread: Post #4 and #5 (this one) is a help/support note and you can skip it

@MichealP: You didn't say if you are on Windows/Linux or Mac

You can find some information on how to apply patches in Windows here: http://drupal.org/node/60179

There's also a discussion here: http://drupal.org/node/14231

The basic steps involved are:

1. Download the 6.x-dev version of vote_up_down
2. Unzip the 6.x-dev version
3. Download the patch and save it in the directory created in step 2.
4. Apply the patch as described in the links above (On Linux the command would be patch -p0 < ctools-plugin.patch)

You should now have the changes merlinofchaos implemented

Hope this helps!

 
 

Drupal is a registered trademark of Dries Buytaert.