How to split up the renderd page in a tpl file? In my D7 template I have a tpl file called:

html--events.tpl.php

  &lt;html class="no-js" lang="&lt;?php print $language-&gt;language; ?&gt;" dir="&lt;?php print $language-&gt;dir; ?&gt;"&lt;?php print $rdf_namespaces; ?&gt;&gt;
&lt;?php endif; ?&gt;
&lt;head&gt;
  &lt;?php print $head; ?&gt;
  &lt;title&gt;&lt;?php print $head_title; ?&gt;&lt;/title&gt;
  &lt;?php print $styles; ?&gt;
  &lt;?php print $scripts; ?&gt;
&lt;/head&gt;
&lt;body&lt;?php print $attributes;?&gt;&gt;
  &lt;a href="#main-content" class="element-invisible element-focusable"&gt;&lt;?php print t('Skip to main content'); ?&gt;&lt;/a&gt;

  &lt;?php print $page_top; ?&gt;
  &lt;?php print $page; ?&gt; 
  &lt;?php print $page_bottom; ?&gt;

&lt;/body&gt;
&lt;/html&gt;


I would like to add a page header image to this page by changing the template.

So therefore I would like to split the rendered content of this page for e.g. like this:

  &lt;?php print $page_top; ?&gt;
  &lt;?php print $pageheader; ?&gt; 
  &lt;?php print "&lt;div&gt;&lt;img src='sites/default/files/animage.png'&gt;/div&gt;" ?&gt; 
  &lt;?php print $pagetitle; ?&gt; 
  &lt;?php print $pagemaincontnet; ?&gt; 
  &lt;?php print $page_bottom; ?&gt;


However the var $page contains already all the rendered header. How can I split the rendered page into smaller blocks? I tried to replace:

&lt;?php print $page; ?&gt; 


into

 &lt;?php print render($page['content']); ?&gt;


but then got a message : Only variables can be passed by reference

Any suggestion is very welcome.
$page is the rendered content from page.tpl.php - you can't alter it in the HTML template without resorting to nasty string manipulation.

Fortunately your desired output lends itself nicely to being handled in the page template anyway. You won't automatically have the same template name suggestions available, although a theme/module might already make them available in your installation. If not, you can add it yourself:

function MYTHEME_preprocess_page(&amp;$vars) {
  // This condition may need to change depending on your exact needs
  if (arg(0) == 'events' &amp;&amp; !arg(1)) {
    $vars['theme_hook_suggestions'][] = 'page__events';
  }
}


Then in page--events.tpl.php you'll have access to the individual elements of the $page array, and you can render them as needed.