I'd like to add a simple drupal_alter() so that we can alter the widget type based on information in the node object.

I see this as a reasonable stopgap for the Drupal 6.x-3.x branch since #793048: Per content configuration is postponed.

My motivation is to have a single site using Vote Up/down with 2 different widgets depending on the node type.

Files: 
CommentFileSizeAuthor
#3 1398942-vote_up_down_node_widget_alter.patch2.52 KBezra-g
PASSED: [[SimpleTest]]: [MySQL] 129 pass(es).
[ View ]
vote_up_down_node_widget_alter.patch1.18 KBezra-g
PASSED: [[SimpleTest]]: [MySQL] 129 pass(es).
[ View ]

Comments

Status:Needs review» Needs work

Sounds pretty reasonable.

+++ b/vud.api.php
@@ -70,3 +70,16 @@ function hook_vud_votes(&$votes) {
+function hook_vud_node_widget_alter(&$widget, $node) {

Please move the this documentation to vud_node/vud_node.api.php and I could push your patch.

Actually there are some other places where we should add the alter too:

$ git grep -n "variable_get('vud_node_widget'"
vud_node/views/vud_node_handler_field_widget.inc:42:        $widget_type = variable_get('vud_node_widget', 'plain');
vud_node/vud_node.module:88:    '#default_value' => variable_get('vud_node_widget', 'updown'),
vud_node/vud_node.module:149:        $widget = variable_get('vud_node_widget', 'plain');
vud_node/vud_node.module:256:      $widget_theme = variable_get('vud_node_widget', 'plain');

Status:Needs work» Needs review
StatusFileSize
new2.52 KB
PASSED: [[SimpleTest]]: [MySQL] 129 pass(es).
[ View ]

Thanks for the fast review!

Here's a re-roll with slightly updated documentation.

I left out altering vud_node/vud_node.module:88:    '#default_value' => variable_get('vud_node_widget', 'updown'), since that's where we set the default and the purpose of the new hook is to alter the default on a per-node basis.

Thanks!

Title:Make widget type alterable through codeMake vud_node widget type alterable through code
Status:Needs review» Fixed

Sorry for the delay here. Thanks for the patch, added to 6.x-3.x.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.