Created
March 10, 2014 00:55
-
-
Save LeShadow/9457610 to your computer and use it in GitHub Desktop.
laravel baseController function to be able to pass on standard settings defined in an array to your view.
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
BaseController.php, add the following: | |
protected function show_view($view, $tempData="") | |
{ | |
$settings = array('setting1'=>'value'); | |
$data = array(); | |
if($tempData != "") | |
{ | |
$data['data'] = $tempData; | |
} | |
$data['settings'] = $settings; | |
$this->layout->content = View::make($view, $data); | |
} | |
now in every controller you want to show a view, you can do this: | |
$this->show_view('viewname'); | |
or if you want to pass on data: | |
$this->show_view('viewname', $data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment