Closed (fixed)
Project:
Zen
Version:
6.x-1.1
Component:
PHP Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Feb 2010 at 18:12 UTC
Updated:
1 Dec 2010 at 09:53 UTC
Hello,
I would like to add a region that should appear under node content and before comments.
I tried editing page.tpl.php in order to create a region on the desired position but I realized there's only one "content" variable which also includes both content and comments. I tried to add the region in comments.tpl but it didn't work and I asked myselft whether it's a good practise or not, since I have read that regions should be added into page.tpl.php file only (otherwise that region shouldn't be displayed on pages or views which don't have comments), so I reverted changes.
Can anyone help me, please?
Thank you
Comments
Comment #1
johnalbinActually, regions can only be added to page.tpl, because Drupal renders regions and only puts those variables into the page.tpl.
If you really need a region between the node and comments and not some other variable, you could re-use some of the code in theme_blocks() from inside YOURTHEME_preprocess_node().
Something like:
if ($list = block_list('my_node_tpl_region')) {, etc., etc. And then saving the the results of the rendered region in a $vars['my_node_tpl_region'] var.Comment #2
c-c-m commentedThank you very much for your information. Unfortunately I couldn't understand much about it. Can you please explain it a little bit for dummies?
thanks again.
Comment #3
Patrick Mowrer commentedI was just wondering the same exact thing and happened to stumble on the commentblock module. It extracts the comments from $content and lets you position it in any region as a block. Hope that helps.
Comment #4
Patrick Mowrer commentedThough the comment block module is pretty cool, it caused some unwanted side-effects, like removing "Add new comment" from node's $links. Perhaps there's a proper way to deal with that, but I couldn't figure it out. I disabled comment block, but to my surprise the content I had added between the node's content and it's comments was still showing up in the right place. I had assumed that node.tpl's $content variable included comments, but that wasn't the case.
Adding the region is then pretty simple:
1. Define it in mytemplate.info.
2. Add it to mytheme's template.php:
3. Print the region below $content in node.tpl.php:
Comment #5
nevets commentedDepending on what you want in the region you might find the block reference and/or display suite modules useful.
Comment #6
akalata commentedAnother way I've accomplished this is using the comment_display module - http://drupal.org/project/comment_display, which gives you a $comments variable that you can play with as if it were a region.
Comment #7
manuel garcia commented#4 got it right.