Last active
August 29, 2015 14:11
-
-
Save maximilianoraul/ff2316fe123ca8f54e87 to your computer and use it in GitHub Desktop.
Flight Micro-Framework - Rendering Views with custom Layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1><?php echo $text; ?></h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//####### Include Flight ####### | |
require_once 'flight/Flight.php'; | |
//######## Rendering Views with custom Layout ####### | |
Flight::map('renderView', function($view = '', $data = array(),$title = 'Default Title'){ | |
Flight::render($view, $data, 'body_content'); | |
Flight::render('layout', array('title' => $title)); | |
}); | |
//####### Routes ######### | |
Flight::route('GET /', function() { | |
//Use map function renderView() to render views | |
Flight::renderView('custom_view',array('text'=>'Hello World!')); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title><?php echo $title; ?></title> | |
</head> | |
<body> | |
<?php echo $body_content; ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment