Hello everybody!
Please, help me to manage the situation I have:
I am rather new to Drupal, so all that is written below can be a one huge mistake:) If you can, please correct it. As I understood from multiple manuals, the hierarchy in templating of Dtupal system in common case is as such : page.tpl.php>node.tpl.php>(block.tpl.php & commnet.tpl.php). I have several blocks of very different layout and content, and I am not using node.tpl.php file for displaying them at all. Instead of this I wrote such code in page.tpl.php file where I need to place each block:
<?php
$feature = module_invoke('block', 'block', 'view', 5);
print $feature['content'];
?>
Is it correct approach? Or should I use any other, which take into consideration node.tpl.php file some how? If I should to do that, how is it possible to do?
Many thanks for your help!
Comments
Mistake
You're making a mistake because you're hardwiring your page layouts rather than taking advantage of the regions system. If you need additional arbitrary regions in which to place blocks, define them in template.php as documented in the theme developer's handbook.
yep, regions
yelvington is correct. You should read up on regions in the handbook. Also note that blocks have nothing to do with node.tpl.php. Blocks are displayed in regions (you set that in the admin interface) and then you can print the regions where ever you want them in your page.tpl.php.
For an example, you can create a new region (following that handbook page above) that is something like
'ad_top' => t('Ad Top'). Then in your block admin you can put whatever block(s) you want in that region. You then simply add a<?php print $ad_top; ?>in your page.tpl.php wherever you want it to display and style as needed.Drupalize.Me, The best Drupal training, available all the time, anywhere!
regions...
Ok, thanks for both answers. But you see in what one more my trouble is:
as far I know(I have already read about regions before doing this) in page.tpl.php to insert content region we need simply to output a variable with the name of this region. for example:
page.tpl.php:
I found a lot of ways to customize the layout of blocks, pages, nodes even users by creating such files as:
page-node-edit.tpl.php
page-node-1.tpl.php
page-node.tpl.php
page.tpl.php
page-user-1.tpl.php
page-user.tpl.php
page.tpl.php etc.
but not regions. Between my blocks there is a layout that I should keep in line with. I am able to create regions and put blocks there but how can I customize the blocks output(markup) inside the region?(weight of blocks is not considered)
Thanks in advance.
Never give up
You can have a variety of
You can have a variety of block template files (block.tpl.php; block-modulename-delta.tpl.php let's you get at each specific one if you need to) to control the layout of each *block* itself. Seems to me though, if you are looking how to control space *between* blocks that you should create a region for each special block, put only one block in each region (so essentially each region = a block) and then you can move them around and be as precise as you want with your page.tpl.php HTML around each region and CSS.
Drupalize.Me, The best Drupal training, available all the time, anywhere!
Thanks add1sun
I am appreciate your quick full answers. Thanks. I'll try to do that. Have you any IM?:)
Never give up
Just a quick question in the
Just a quick question in the same vein, what if I want a block in a defined region, but only want the block to appear on certain pages?
ie, in the 'footer' region of my 'about-me' page?
Two seconds later I find it
Two seconds later I find it under 'Page specific visibility settings' in the block configuration view :D
Sorry guys!