0
votes

I am starting with Drupal 7 theming. In my page.tpl.php I would like to print the title a and content separately. If I use print render($page['content']); it works fine and diplays title and content. But print $title; does nothing. Also, I would like to know how to render the content without the title. This is something I would expect to be straightforward, but is not. I googled suggestions about adding a page title plugin, but I refuse to believe there is no simpler way.

I got my info from https://api.drupal.org/api/drupal/modules%21system%21page.tpl.php/7.x I am not using any custom preprocess functions, I suppose Drupal should give me the $title var itself. I see other themes using the variable, but in my case it is not passed to the template.

I tried checking the the core bartik theme and modified page.tpl.php only to get the same behaviour and results as with my own theme.

2

2 Answers

0
votes

Short answer: $title works on every page EXCEPT the frontpage. I edited node.tpl.php and used the $title variable there instead.

more info here: https://www.drupal.org/forum/support/theme-development/2008-06-02/title-variable-is-empty-in-pagetplphp

0
votes

In my years working with Drupal 7, I have not found a better way to easily hide the title on a node than with Exclude Node Title at https://www.drupal.org/project/exclude_node_title . It's a tiny plugin (56K uncompressed) and quite in line with the Drupal mantra: include only the very basics. Allow extra functionality via modules.