summaryrefslogtreecommitdiff
path: root/modules/poll/poll.module
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-13 05:40:03 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-13 05:40:03 +0000
commit02d2f6e04a29acb1c3fcedcd5068878cffb10fbf (patch)
tree48d65b410f2dc34eaf8d69a822a09ec83e9d85df /modules/poll/poll.module
parent5d2cdb6ba95549da448e0a127e40fcc375e3886c (diff)
downloadbrdo-02d2f6e04a29acb1c3fcedcd5068878cffb10fbf.tar.gz
brdo-02d2f6e04a29acb1c3fcedcd5068878cffb10fbf.tar.bz2
#678714 by effulgentsia: Unify use of theme hook / template suggestions, fix clobbering problems, and improve suggestion discovery performance.
Diffstat (limited to 'modules/poll/poll.module')
-rw-r--r--modules/poll/poll.module25
1 files changed, 19 insertions, 6 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index c2d759048..841510c59 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -38,7 +38,7 @@ function poll_init() {
* Implements hook_theme().
*/
function poll_theme() {
- return array(
+ $theme_hooks = array(
'poll_vote' => array(
'template' => 'poll-vote',
'render element' => 'form',
@@ -55,6 +55,21 @@ function poll_theme() {
'variables' => array('title' => NULL, 'votes' => NULL, 'total_votes' => NULL, 'vote' => NULL, 'block' => NULL),
),
);
+ // The theme system automatically discovers the theme's functions and
+ // templates that implement more targeted "suggestions" of generic theme
+ // hooks. But suggestions implemented by a module must be explicitly
+ // registered.
+ $theme_hooks += array(
+ 'poll_results__block' => array(
+ 'template' => 'poll-results--block',
+ 'variables' => $theme_hooks['poll_results']['variables'],
+ ),
+ 'poll_bar__block' => array(
+ 'template' => 'poll-bar--block',
+ 'variables' => $theme_hooks['poll_bar']['variables'],
+ ),
+ );
+ return $theme_hooks;
}
/**
@@ -733,9 +748,8 @@ function template_preprocess_poll_vote(&$variables) {
$variables['vote'] = drupal_render($form['vote']);
$variables['rest'] = drupal_render_children($form);
$variables['block'] = $form['#block'];
- // If this is a block, allow a different tpl.php to be used.
if ($variables['block']) {
- $variables['template_files'][] = 'poll-vote-block';
+ $variables['theme_hook_suggestions'][] = 'poll_vote__block';
}
}
@@ -833,9 +847,8 @@ function template_preprocess_poll_results(&$variables) {
}
$variables['title'] = check_plain($variables['raw_title']);
- // If this is a block, allow a different tpl.php to be used.
if ($variables['block']) {
- $variables['template_files'][] = 'poll-results-block';
+ $variables['theme_hook_suggestions'][] = 'poll_results__block';
}
}
@@ -850,7 +863,7 @@ function template_preprocess_poll_results(&$variables) {
*/
function template_preprocess_poll_bar(&$variables) {
if ($variables['block']) {
- $variables['template_files'][] = 'poll-bar-block';
+ $variables['theme_hook_suggestions'][] = 'poll_bar__block';
}
$variables['title'] = check_plain($variables['title']);
$variables['percentage'] = round($variables['votes'] * 100 / max($variables['total_votes'], 1));