Hi,
Sorry for my bad english (I'm french and not very good in english)
I have setup several pages in my views/pages folder. Instead of create one route per page (and thus the page itself), I just want to create the page and then parse the pages folder to create the route.
In routes.php I have the following code :
$dirname = base_path().'/app/views/pages/';
$dir = opendir($dirname);
$filelist = array();
while($file = readdir($dir)) {
if($file != '.' && $file != '..' && !is_dir($dirname.$file))
{
$filearray = explode('.', $file);
array_push($filelist, $filearray[0]);
}
}
closedir($dir);
foreach ($filelist as $page) {
Route::get(
$page,
function()
{
return View::make('home');
}
);
}
The return View::make($page) statement doesn't recognize my $page variable, how can I do?
Try this.
foreach ($filelist as $page) {
Route::get(
$page,
function() use ($page)
{
return View::make( $page );
}
);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community