Kirby->render() without header and footer


I’m palying around with the $kirby->render('mypage) function. My goal is to load the content from another page in my home template. I use render() because the other page has a controller which has to be included too. So the render() function works great.
But I wonder if it’s possible to strip the header and the footer?
In my other template I tried somethings like

  if(!$page->isHomePage()) {

But this isn’t working obviously because the $page object returns the rendered page and not the actual page.
Is there an other way to get around this?


You could refactor the contollers and move the stuff you need to use in multiple places to a shared controller. Then you should be able to access the bits of the page you want without render().


The render function allows you to send additional data to the template. So I think you should be able to send a variable that you can then use to check if the header/footer should get included or not.


Thanks for your answers…
I will check the sending of variables. But is there some documentation about the render function? Couldn’t find anything.


Don’t think so, the source code is the documentation :wink:

public function render(Page $page, $data = array(), $headers = true) {
  // render function


Template where other page gets rendered

$data = ['includeSnippet' => false];
tpl::$data = array_merge(tpl::$data, array(
    'kirby' => kirby(),
    'site'  => site(),
    'pages' => site()->children(),
), page('homepage')->controller($data));

echo $kirby->render(page('somepage'), $data);

Somepage controller:

return function($site, $pages, $page, $args) {
  $includeSnippet = isset($args['includeSnippet'])?$args['includeSnippet']:true;
  // other controller stuff
  return compact('includeSnippet')


Somepage template:

<?php if($includeSnippet) snippet('header') ?>
<!-- main template code that should get rendered in the other page -->
<?php if($includeSnippet) snippet('footer') ?>


Thanks, @texnixe for your effort. For me, I’m happy with

$kirby->render(page($content->subpage()), array('layout' => 'home'));

and so: problem solved.


Perfect, for me, that didn’t work as expected when I tested it, so I went for something more complicated.