Exemple #1
0
/**
 * Implementation of theme_blocks().
 *
 * Print dividers after each second, third or fourth block. These can be used
 * to 'clear' them. This makes it easy te make rows of two, three or four blocks.
 */
function csa_base_blocks($region)
{
    $output = '';
    $block_list = block_list($region);
    $block_count = count($block_list);
    if ($block_count) {
        $i = 1;
        foreach ($block_list as $key => $block) {
            $classes = array();
            $output .= theme('block', $block);
            if ($i % 5 == 0) {
                $classes[] = 'after-fifth-block';
            }
            if ($i % 4 == 0) {
                $classes[] = 'after-fourth-block';
            }
            if ($i % 3 == 0) {
                $classes[] = 'after-third-block';
            }
            if ($i % 2 == 0) {
                $classes[] = 'after-second-block';
            }
            if ($i == $block_count) {
                $classes[] = 'after-last-block';
            }
            if (count($classes) > 0) {
                $output .= '<div class="' . implode(' ', $classes) . '"></div>' . "\n";
            }
            $i++;
        }
    }
    // Add any content assigned to this region through drupal_set_content() calls.
    $output .= drupal_get_content($region);
    return $output;
}
Exemple #2
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) : '';
    }
}
Exemple #3
0
/**
 * Implementation of theme_block
 *
 * @see theme_block()
 *
 * Added first and last class to all blocks for styling.
 */
function eepotts_blocks($region)
{
    $output = '';
    if ($list = block_list($region)) {
        $counter = 1;
        foreach ($list as $key => $block) {
            $block->firstlast = '';
            if ($counter == 1) {
                $block->firstlast .= ' first';
            }
            if ($counter == count($list)) {
                $block->firstlast .= ' last';
            }
            $output .= theme('block', $block);
            $counter++;
        }
        //$block->count = count($list);
    }
    $output .= drupal_get_content($region);
    return $output;
}
Exemple #4
0
/**
 * 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)
{
    static $list;
    $output = '';
    $list = module_exists('context') && function_exists('context_block_list') ? context_block_list($region) : block_list($region);
    // Allow theme functions some additional control over regions
    if ($list) {
        $registry = theme_get_registry();
        if (isset($registry['blocks_' . $region])) {
            $output .= theme('blocks_' . $region, $list);
        } else {
            foreach ($list as $key => $block) {
                $output .= theme("block", $block);
            }
            $output .= drupal_get_content($region);
        }
        return $output;
    }
    return '';
}
Exemple #5
0
function urbanmediaspace_blocks($region, $show_blocks = NULL)
{
    if (module_exists("context")) {
        // 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;
        }
        // Is the Context module enabled? If so make sure that the blocks Context wants to display get displayed
        if ($region) {
            $output = '';
            if (module_exists("context")) {
                // Get the Context plugin needed to get the blocks that needs to be displayed for this region
                $plugin = context_get_plugin('reaction', 'block');
                // Let's get the blocks that should be displayed from Context.
                if (is_object($plugin)) {
                    $output .= $plugin->execute($region);
                }
            } else {
                // If $renders_sidebars is FALSE, don't render any region whose name begins
                // with "sidebar_".
                if (($render_sidebars || strpos($region, 'sidebar_') !== 0) && ($list = block_list($region))) {
                    foreach ($list 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;
            return $output ? theme('region', $elements) : '';
        }
    } else {
        return zen_blocks($region, $show_blocks);
    }
}
Exemple #6
0
/**
 * 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)
{
    // Bail if this region has been disabled through context.
    if (module_exists('context')) {
        $disabled_regions = context_active_values('theme_regiontoggle');
        if (!empty($disabled_regions) && in_array($region, $disabled_regions)) {
            return '';
        }
    }
    $output = '';
    $list = module_exists('context') && function_exists('context_block_list') ? context_block_list($region) : block_list($region);
    if (!empty($list)) {
        // Allow theme functions some additional control over regions
        $registry = theme_get_registry();
        if (isset($registry['blocks_' . $region])) {
            return theme('blocks_' . $region, $list);
        }
        // Otherwise, flow through regular stack
        foreach ($list as $key => $block) {
            $output .= theme("block", $block);
        }
    }
    return $output . drupal_get_content($region);
}