drupal different templates based on blocks
How to create different template files depending on various factors.
I had a situation where i wanted a left column on some page while 100% width in the rest. But this requriement was complicated as i could not categorize it. I wanted left column in the description of a particular content type and 100% width on most of the view pages but not all.
The solution was to have the left column as a block and check in the page.tpl file that if the block is enabled then use a div with width = 50% else width = 100%
Eg the left column was in a block called “left_sidebar” so go in the page.tpl file use the following code:
Where $left_sidebar is a region defined in template.tpl file, $content is drupal variable to display content, left_div, wide_div and narrow_div are custom classes for your stylesheet (.css) file
<?php if ($left_sidebar): ?>
<div id="left_div">
<?php print $left_sidebar?>
</div>
<div id="wide_div">
<?php print $content?>
</div>
<?php else: ?>
<div id="narrow_div">
<?php print $content?>
</div>
<?php endif; ?>