I've created a custom Vote Up/Down widget based on the instructions in WIDGETAPI.txt. However, I can't figure out where to do preprocessing for the widget template. I have some code that calculates the upvotes and downvotes separately, and I'd like to avoid putting that code directly in widget.tpl.php. Is there a widget preprocess hook that I'm overlooking? My theme's hook_preprocess does not seem to get called for the widget.

I know this isn't strictly a Vote Up/Down issue - let me know if there's a better place for this.

Comments

marvil07’s picture

Title: preprocessing for custom widget? » add a hook to preprocess variables passed to widget.tpl.php
Category: support » task

You are right, since we are using plugins for this, and we call the render function directly there is not time for making preproces as in theme system :-/

But, for now, you can manually change the render function item on your widget definition(at hook_vud_widgets()), so there you can call an own function to do preprocess and then call the expected theme_render_template().

Please take a look at vud_widget_proxy() function definition to see the relevant code.

I'm planning to make this on a hook, but if someone have other alternatives it would be great to hear about it.

marvil07’s picture

Status: Active » Closed (duplicate)

I'm preparing a major patch for theming, so I'll going to update on #821048: make widgets easy to theme