Download & Extend

add a hook to preprocess variables passed to widget.tpl.php

Project:Vote Up/Down
Version:6.x-2.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

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

#1

Title:preprocessing for custom widget?» add a hook to preprocess variables passed to widget.tpl.php
Category:support request» 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.

#2

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

nobody click here