Code Monkey home page Code Monkey logo

pages's Introduction

Micro Pages

Latest Stable Version Total Downloads

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

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

    'Micro\Pages\PagesServiceProvider',

Add Facade to the Facades array app/config/app.php

    'Micro\Pages\Support\Facades\Pages',

Add the following in your app/routes.php

best would be to add this at the end. This will CATCH all routes.

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 :

$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 :

[{
    "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.

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.

As long as you are using eloquent this should work fluent-ly ;)

    'database' => array(
            'table'       => 'pages',
            'id'          => 'id',
            'parent_id'   => 'parent_id',
            'language_id' => 'language_id',
            'title'       => 'title',
            'content'     => 'content'
        ),

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.