function _disqus_block_content in Disqus 7
Helper function for disqus widget blocks content.
Parameters
$function: Name of the function (widget) that needs to be returned. Same as widget API call name (w/o .json suffix).
$options: Options array (query variables, domain, ...).
Return value
Render array that can be directly used for block content.
1 call to _disqus_block_content()
- disqus_block_view in ./
disqus.module - Implements hook_block_view().
File
- ./
disqus.module, line 704 - The Disqus Drupal module.
Code
function _disqus_block_content($function, $options) {
$configuration = array(
'recent_comments_widget' => array(
'id' => 'dsq-recentcomments',
'query_items' => array(
'num_items',
'excerpt_length',
'avatars',
),
),
'popular_threads_widget' => array(
'id' => 'dsq-popthreads',
'query_items' => array(
'num_items',
),
),
'top_commenters_widget' => array(
'id' => 'dsq-topcommenters',
'query_items' => array(
'num_items',
'hide_mods',
'avatars',
),
),
'combination_widget' => array(
'id' => 'dsq-combinationwidget',
'query_items' => array(
'num_items',
'hide_mods',
'excerpt_length',
'color',
'default_tab',
),
),
);
if (empty($configuration[$function])) {
return FALSE;
}
$query = array();
foreach ($configuration[$function]['query_items'] as $query_item) {
if ($query_item == 'avatars') {
$query += $options[$query_item];
}
else {
$query[$query_item] = $options[$query_item];
}
}
return array(
'widget' => array(
'#theme' => 'html_tag',
'#tag' => 'script',
'#value' => '',
'#attributes' => array(
'type' => 'text/javascript',
'src' => url("//disqus.com/forums/{$options['domain']}/{$function}.js", array(
'external' => TRUE,
'query' => $query,
)),
),
),
'#theme_wrappers' => array(
'container',
),
'#attributes' => array(
'id' => $configuration[$function]['id'],
'class' => array(
'dsq-widget',
),
),
);
}