Single Page template not working as expected

Permalink 1 user found helpful
Hi all,
I have a single page that I don't want to use my theme's view.php but would rather create a custom template for.

I created a page in my theme of the same name as the single page the contents of which are:

<?php  
defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php print $innerContent; ?>


The template is being used instead of view.php - but my single page content is not being output at $innerContent - this variable is an empty string at time of rendering. If I delete the template, view.php renders the single page as expected, I add the template back in and I get nothing.

The page object does exist in the template file,

I just did a fresh install of 5.6.0.2 last night and advanced permissions are enabled. Anyone have any thoughts?

Thanks,

Gerry

snowbound
 
mesuva replied on at Permalink Best Answer Reply
mesuva
When you override a single page by creating it in your theme, you then need to include in it ALL of the contents of the single page- it no longer looks at the original location for the contents of the single page (which it would normally load into the $innerContent variable), it simple looks at your override file for everything to output.

To explain it another way - an overridden single page is NOT a template/wrapper like view.php, it is both the wrapper as well as the contents of the single page itself.

So as an example.

If your original single page has:
HELLO WORLD, it's <?php echo date('Y'); ?>


And your theme's view.php has:
<?php  defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php $this->inc('elements/header.php'); ?>
<div id="body">
<?php  print $innerContent; ?>
</div>
<?php  $this->inc('elements/footer.php'); ?>


When you override the single page by putting it in your theme it would look like:
<?php  defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php $this->inc('elements/header.php'); ?>
<div id="body">
HELLO WORLD, it's <?php echo date('Y'); ?>
</div>
<?php  $this->inc('elements/footer.php'); ?>
snowbound replied on at Permalink Reply
snowbound
Hi Mesuva, I thought that you could override in the theme and it would carry the content from the single page into $innerContent but wasn't certain. Thanks for sorting me out.

Gerry
incredikill replied on at Permalink Reply
But how do i implement the style? I cant just fill innerContent can i? Do i have to put the single_page in the themes folder?