Override region content.

Is it possible to programatically over-ride what gets rendered in a specific region on a specific page
When i say over-ride i mean doing this even if a block has been set to display in that region from the GUI back end.

Comments

nevets’s picture

You can do that without programing using the context module.

cmsMinds’s picture

Hello

We can add preprocess function for regions such that we can add customization before rendering the region template file(.tpl.php).

Sometimes we may even want edit the template file(.tpl.php) for specific content such as a content type node view. In Omega theme, there are different regions and by default they will use the following template files.

/sites/all/themes/omega/omega/templates

Let’s say if you want to have your own region--content.tpl.php for the article content type.

1. Copy the above region--content.tpl.php to /sites/all/themes//templates/.

2. Rename it to region--content--article.tpl.php and edit it for your own customization.

3. Create the /sites/all/themes//preprocess/preprocess-region.inc

<?php
function _alpha_preprocess_region(&$vars) {
$menu_object = menu_get_object();
if (isset($menu_object->type) && $vars['region'] == 'content') {
if ('article' == $menu_object->type) {
$vars['theme_hook_suggestions'][] = 'region__content__article';
}
}
}

4. Clear cache and your new .tpl.php should be applied.