2017 © Pedro Peláez
 

library pages

Simple URL to page delegation

image

micro/pages

Simple URL to page delegation

  • Tuesday, June 24, 2014
  • by donseba
  • Repository
  • 1 Watchers
  • 4 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Micro Pages

Latest Stable Version Total Downloads, (*1)

Micro Pages is an component to translate URL slugs http://domain.tld/slug-1/slug-2/slug-3 and find the respective resources., (*2)

Drivers working on

  • Json -> Local json file with all page content
  • Database -> use the database connection to get contents relative to the slug.

Drivers to come

  • JsonE -> fetch results from external Json source
  • XML -> For the enterprise ^-^

Installation in Laravel 4.x

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',
);

Examples

JSON Configuration File

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"
        }
    }
}]

Database Driver

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'
        ),

The Versions

24/06 2014

dev-master

9999999-dev

Simple URL to page delegation

  Sources   Download

MIT

The Requires

 

by Sebastiano Bellinzis

laravel pages