title: Concrete5 - how to manually render a single page
body: <p>So I'm developing a site that wants to display all of the pages on the home page (for the most part). In doing so, I'm trying to make this easy to manage for the client by giving them actual pages to edit for each 'section' of the site. However that is providing more challenging than I thought.</p>
  
  <p>The current code I have is this:</p>
  
  <pre><code>&lt;?php 
  
    defined('C5_EXECUTE') or die("Access Denied.");
  
    global $c;
    $old_c = $c;
  
    // render page object
    $_v = View::getInstance();
    $old_theme = $_v-&gt;getTheme();
    $oldDirectory = $_v-&gt;getThemeDirectory();
  
    // change theme
    $theme = PageTheme::getByHandle('blankTheme');
    $_v-&gt;setTheme($theme);
  
    foreach ($pages as $page) {
  
      if ($page-&gt;getCollectionID() != HOME_CID) {
  
        $c = $page;
  
        $page_name = strtolower( $c-&gt;getCollectionName() );
  
        // start output buffering
        $_v-&gt;setCollectionObject($c);
  
        ob_start();
        $_v-&gt;render('default');
        // get page content
        $content = ob_get_contents();
        // stop output buffering
        if (ob_get_level() &gt; OB_INITIAL_LEVEL) {
           ob_end_clean();
        }
  
        // process page content..
        echo "&lt;section id='$page_name'&gt;$content&lt;/section&gt;";
  
      }
  
    }
  
    $c = $old_c;
    $_v-&gt;setTheme($oldTheme); // precaution
    $_v-&gt;setThemeDirectory($oldDirectory); // precaution
  
    // Because the above doesn't work in resetting it for some crazy reason
    $_v-&gt;ptHandle = "newTheme";
    $_v-&gt;theme = str_replace('blankTheme', 'newTheme', $_v-&gt;theme);
    $_v-&gt;themePath = str_replace('blankTheme', 'newTheme', $_v-&gt;themePath);
    $_v-&gt;themeDir = str_replace('blankTheme', 'newTheme', $_v-&gt;themeDir);
    $_v-&gt;themePkgID = 0;
  
  ?&gt;
  </code></pre>
  
  <p>You'll already notice some 'funky' stuff in there - namely the whole theme change. Let me explain - this is a page list template. It takes in the pages, assigns them to be '$c' and then proceeds to try and render the page view. Normally, this would include the header and the footer however we have created a new theme called "blankTheme" (our current theme being called "newTheme") which contains an empty header and footer, as there is no real way to output this otherwise it seems - I've tried creating 'empty' templates within the same theme but they are never picked up.</p>
  
  <p>So at least this seemed to work. However, I have another problem now in that when it tries to render a single page, it doesn't pick up any content whatsoever, and just returns me empty content. I've tried all sorts of methods to get the single page content to show, but no matter what I do it's always blank. The only time it renders is when loading the page up by visiting the URL. Even when I change the render action to be</p>
  
  <pre><code>$_v-&gt;render($c);
  </code></pre>
  
  <p>I still get nothing back (I'm aware in the example I'm using 'default', but I've tried setting it to the single pages name with still no avail). </p>
  
  <p>There is definitely content on the page, however it will not render any of it (not even the HTML) and $innerContent is definitely empty.</p>
  
  <p>I've asked similar things in the past and have had no joy, however seeing as I've just wasted a few hours of my life on this, I feel I have to at least ask. So if you have any ideas, it would be amazing to hear them.</p>
  
  <p>Thank you for taking the time to read. </p>
  
  <p>Dan.</p>