Active
Project:
Content Templates (Contemplate)
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
19 Apr 2009 at 12:54 UTC
Updated:
20 Apr 2009 at 19:11 UTC
I'm using the latest version for d6. I need to show 2 different nodes of a content type on the front page, with different formatting.
I created a different block for each of the two regions, and template file for the content type. The template file is being hit...contemplate tells me it's reading from it, and the two regions show output. The problem is that I cannot find a way to specify in the template which region the output is for. The two regions are $user1 and $user2, and if I put if($user2){ , for example, nothing inside is touched.
Comments
Comment #1
j. ayen green commentedI stumbled upon the answer. I'll document it here for anyone having the problem.
To access a region name, for example $user2, in the template, simply put
global $user2;at the top of the template. Then, you'll be able to put if($user2){ } around the formatting you want to pass only to that region.
Comment #2
j. ayen green commentedI take it back...I thought the global was working, but when I cleared cache, I had no output for either region. So I'm back to asking...how do I check which region I'm creating content for while in the template?
Comment #3
nevets commentedYou can use $block->region in block.tpl.php, for more block.tpl.php variables see http://api.drupal.org/api/file/modules/system/block.tpl.php/6
Comment #4
jrglasgow commentedYour template is processed in the nodeapi's 'alter' step. The information about what region the node will be placed in is not available to Content Templates.
I have 2 suggestions...