dev-master
9999999-devSimple URL to page delegation
MIT
The Requires
- php >=5.4.0
- illuminate/support ~4.0
by Sebastiano Bellinzis
laravel pages
Wallogit.com
2017 © Pedro Peláez
Simple URL to page delegation
Micro Pages is an component to translate URL slugs http://domain.tld/slug-1/slug-2/slug-3 and find the respective resources., (*2)
Add provider to the Providers array app/config/app.php, (*3)
'Micro\Pages\PagesServiceProvider',
Add Facade to the Facades array app/config/app.php, (*4)
'Micro\Pages\Support\Facades\Pages',
Add the following in your app/routes.php, (*5)
best would be to add this at the end. This will CATCH all routes., (*6)
Route::any('{all}', function() {
return View::make('base')->with('pages', Pages::getPage() );
})->where('all', '.*');
Replace base with the view you want to use for your pages. For now $page will consist of the following :, (*7)
$page = array(
'id' => (int) 1
'parent_id' => (int) 0,
'public' => (int) 1,
'title' => (string) 'Page title',
'slug' => (string) 'page-slug',
'content' => (string) 'The content of your page',
);
See the config file for the json file location :, (*8)
[{
"en" => {
"1" => {
"parent_id" => "0"
"slug" => "one",
"title" => "Title of page one"
"content" => "Some content for the first page"
"public" => "1"
},
"2" => {
"parent_id" => "1"
"slug" => "two",
"title" => "Title of second page"
"content" => "Some content for the third page <br/> And additional line of text"
"public" => "1"
},
"3" => {
"parent_id" => "2"
"slug" => "three",
"title" => "Title of page three"
"content" => "Some content for the third page"
"public" => "0"
},
"4" => {
"parent_id" => "0"
"slug" => "four",
"title" => "Title of page four"
"content" => "Some content for the fourth page"
"public" => "1"
}
}
}]
Mandatory of this driver is that it needs an active database connection., (*9)
In the config you need to provite the table to look for, and asign the table fields. This may be different if you are comming from another system., (*10)
As long as you are using eloquent this should work fluent-ly ;), (*11)
'database' => array(
'table' => 'pages',
'id' => 'id',
'parent_id' => 'parent_id',
'language_id' => 'language_id',
'title' => 'title',
'content' => 'content'
),
Simple URL to page delegation
MIT
laravel pages