Hi all,
In my D7 zen theme I want no title displayed for the content type 'page'.
So can anyone please tell me the correct way to do this?
I have tried adding a function to template.php which I have heard works in other themes but for me gives error messages =
I have tried added the following to the bottom of template.php
function zen_process_page(&$variables) {
if($variables['node']->type == 'page') {
$variables['title'] = '';
}
}=
Notice: Undefined index: node in zen_process_page() (line 331 of .../sites/all/themes/zen/template.php).
Notice: Trying to get property of non-object in zen_process_page() (line 331 of .../sites/all/themes/zen/template.php).
line 331 being if($variables['node']->type == 'page') {
OR...
function zen_process_page(&$variables) {
$node = $variables['node'];
if ($node->type == 'page') {
$variables['title'] = '';
}
}=
Notice: Undefined variable: node in zen_process_page() (line 331 of /...sites/all/themes/zen/template.php).
Notice: Trying to get property of non-object in zen_process_page() (line 331 of...sites/all/themes/zen/template.php).
Any suggestions please?
Thank you
Comments
Comment #1
n8tronThis could also be accomplished with CSS:
Comment #2
juc1 commented@ n8tron, thanks for your reply. I tried a variation of your suggestion which seems to work fine:
Is there any problem with this?
Thanks
Comment #3
johnalbinIt depends on if you want the page title to be accessible or not. The "display: none" method means that screen reader users will not be able to read that text.
Also, the problem with your PHP was that not all pages (like the default front page) have a $node variable set. You have to first check for the existence of the variable before you use it; that will prevent the PHP Notices you were getting.
Comment #4
juc1 commented@ JohnAlbin, sorry for being thick but where does your code go? I have added it to the bottom of template.php just before my functioned mentioned above but I am still getting the same error message.
Thank you
Comment #5
PMorris commentedA non-code option I've been using is the Display Suite module. It has really nice customization for content types. You can just set node titles for a content type to be 'hidden'
I'm really liking it so far but I'm not sure if you get a performance hit or not. Haven't run too many tests.
http://drupal.org/project/ds
Comment #6
johnalbinin your sub-theme's template.php file, you need this:
where STARTERKIT is replaced with the actual name of your theme.
Comment #7
johnalbinAlso, I too have heard good things about Display Suite. Though I haven't used it.
Comment #8
tom09 commentedHi,
Sorry I am quite new to Drupal and thus could not figure out how DS can help me to prevent the node title to be displayed. I checked all settings but there was nothing like a "content type to be 'hiddden'". Can you please elaborate a little bit more on the steps to get that working?
Comment #9
johnalbin@tom09 You'll have to ask over in Display Suite's issue queue or in IRC. I have no clue. :-)
Comment #11
joostvdl commented$variables['title'] does not exist. So it can't be override like this.
Comment #12
neek commentednice solution, but after this "home link (sites name)" thinks that this is a frontpage so here is no link to main page from node.
Comment #13
maurice13 commentedHi,
This is ok for me.
Now i want hide title for taxonomy content. How can i do?
Comment #14
johnalbinThe original support request has been closed. Closing again.