Skip to content

Instantly share code, notes, and snippets.

@russelporosky
Created January 28, 2014 22:15
Show Gist options
  • Save russelporosky/8677698 to your computer and use it in GitHub Desktop.
Save russelporosky/8677698 to your computer and use it in GitHub Desktop.
How to make a layout/view combo with AuraView.
<?php
$view_manager = new \Aura\View\Manager(
new \Aura\View\Template,
new \Aura\View\Helper,
new \Aura\View\Finder,
new \Aura\View\Finder
);
echo $view_manager->render(
array(
'someText' => '<p>This is some body text</p>',
'pageTitle' => 'Title of the Page'
),
function() {
// A view file that will be inserted as $content into the layout file.
ob_start();
require('view.php');
echo ob_get_clean();
},
function() {
// A layout file that contains a header, footer and space for the view file contents.
ob_start();
require('layout.php');
echo ob_get_clean();
}
);
<?php
// A layout file. Contains the wrapping HTML tags.
?>
<html>
<head>
<title><?php echo $pageTitle; ?></title>
</head>
<body>
<?php echo $content; ?>
</body>
</html>
<?php
// A view file. The contents of this file will be available to the layout as $content.
?>
<p>This is the view file.</p>
<?php echo $someText; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment