Beispiel #1
0
function krubik_blocks_content($doit = TRUE)
{
    static $blocks;
    if (!isset($blocks)) {
        $blocks = module_exists('context') && function_exists('context_blocks') ? context_blocks('content') : theme_blocks('content');
    }
    return $doit ? $blocks : '';
}
/**
 * Override of theme_blocks().
 * Allows additional theme functions to be defined per region to
 * control block display on a per-region basis. Falls back to default
 * block region handling if no region-specific overrides are found.
 */
function tao_blocks($region)
{
    // Allow theme functions some additional control over regions.
    $registry = theme_get_registry();
    if (isset($registry['blocks_' . $region])) {
        return theme('blocks_' . $region);
    }
    return module_exists('context') && function_exists('context_blocks') ? context_blocks($region) : theme_blocks($region);
}
Beispiel #3
0
/**
 * Return a set of blocks available for the current user.
 *
 * @param $region
 *   Which set of blocks to retrieve.
 * @param $show_blocks
 *   A boolean to determine whether to render sidebar regions or not. Should be
 *   the same value as passed to theme_page.
 * @return
 *   A string containing the themed blocks for this region.
 *
 * @see zen_show_blocks_discovery()
 */
function zen_blocks($region, $show_blocks = NULL)
{
    // Since Drupal 6 doesn't pass $show_blocks to theme_blocks, we manually call
    // theme('blocks', NULL, $show_blocks) so that this function can remember the
    // value on later calls.
    static $render_sidebars = TRUE;
    if (!is_null($show_blocks)) {
        $render_sidebars = $show_blocks;
    }
    // If zen_blocks was called with a NULL region, its likely we were just
    // setting the $render_sidebars static variable.
    if ($region) {
        $output = '';
        // If $renders_sidebars is FALSE, don't render any region whose name begins
        // with "sidebar_".
        if ($render_sidebars || strpos($region, 'sidebar_') !== 0) {
            // Allow context module to set blocks.
            if (function_exists('context_blocks')) {
                $output = context_blocks($region);
            } else {
                foreach (block_list($region) as $key => $block) {
                    // $key == module_delta
                    $output .= theme('block', $block);
                }
            }
        }
        // Add any content assigned to this region through drupal_set_content() calls.
        $output .= drupal_get_content($region);
        $elements['#children'] = $output;
        $elements['#region'] = $region;
        // Set the theme hook suggestions.
        $hook = array('region_' . $region);
        if (strpos($region, 'sidebar_') === 0) {
            $hook[] = 'region_sidebar';
        }
        $hook[] = 'region';
        return $output ? theme($hook, $elements) : '';
    }
}