punn / laymode
This package is abandoned and no longer maintained.
No replacement package was suggested.
A layout system for desktop and mobile
dev-master
2014-05-24 22:37 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.1.*
This package is not auto-updated.
Last update: 2017-04-21 07:51:49 UTC
README
A simple layout mode manager that allows you to customize your pages using "view sets" per page. Also, you get to manage your routes, pages, and views through the Database.
Current Version:
1.0.3
Stage:
Alpha
How to Install:
- Add to
composer.json
:
"require": {
"punn/laymode": "dev-master"
},
- Add
'Punn\Laymode\LaymodeServiceProvider'
to theproviders
array inapp/config/app.php
(Laravel v4.*) - Add
'Layout' => 'Punn\Laymode\Facades\Laymode'
to thealiases
array inapp/config/app.php
- Load a random page you have to create the tables in the database
- Run
php artisan view:publish punn/laymode
in Terminal in the laravel project directory - Add routes to the database
- Add pages matching the route id
- For layout tables like desktop and mobile use this to get you started:
{"top":[{"module":"sets.header.one","class":"","options":[]}],"drawer":[],"content":[{"module":"modules.homepage","class":"","options":[]},{"module":"modules.html","class":"","options":{"payload_id":1}}],"footer":[{"module":"modules.footer.copyright","class":"","options":[]},{"module":"modules.footer.socialbuttons","class":"","options":[]},{"module":"modules.footer.links","class":"","options":[]}]}
or create your own via a temporary route like '/layout' (that you'll need to create):
Route::get('/layout', function() { $layout = array( "top" => array( array( "module" => "sets.header.one", "class" => "", "options" => array() ) ), "drawer" => array( ), "content" => array( array( "module" => "modules.homepage", "class" => "", "options" => array( ) ), array( "module" => "modules.html", "class" => "", "options" => array( "payload_id" => 1 ) ) ), "footer" => array( array( "module" => "modules.footer.copyright", "class" => "", "options" => array() ), array( "module" => "modules.footer.socialbuttons", "class" => "", "options" => array() ), array( "module" => "modules.footer.links", "class" => "", "options" => array() ) ), ); echo "<textarea>" . json_encode($layout) . "</textarea>"; });
- The first level keys "top", "drawer", "content", and "footer" are called 'slots'
- Inside the slots are modules or views with options attached to them via array
- Create a controller called
LayoutController.php
and place in there this:
class LayoutController extends BaseController { public function home() { return Layout::get('home'); } public function detect($page) { return Layout::get($page); } }
- Point your homepage route to use LayoutController and home for action or manually LayoutController@home
- Make sure you have a page named 'home' pointed at the home route id (ex. '/')
- Create a
templates
folder inside theapp
folder - Add a template named
desktop.homepage
to your laymodes_templates db table, don't work about json_slots (in testing) - Create a desktop layout with the json encoded json_views used in the example above... template = id of the homepage template you just created
- Create the
desktop
folder inside thetemplates
folder you created in step 11 - Create a view called
homepage.blade.php
and add the following:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title><?=$page->get_meta_title()?></title>
<? $description = $page->get_meta_description(); ?>
@if(!empty($description) || strlen($description) < 10)
<meta name="description" content="<?=$description?>" />
@endif
@if($page->get_noindex() == '1')<meta name="robots" content="noindex,nofollow" />@else<meta name="robots" content="index,follow,noodp" />@endif
<link rel="canonical" href="{{ url($_SERVER['REQUEST_URI']) }}" />
<meta name="viewport" content = "width=device-width"/>
<!-- DEFAULT STYLES -->
@if($page->get_layout()->get_template_raw())
<link rel="stylesheet" href="/css/output/templates/{{ $page->get_layout()->get_template_raw() }}.css" />
@endif
</head>
<body>
<div id="wrapper" class="page">
{{ Layout::getSlot('top'); }}
{{ Layout::getSlot('drawer'); }}
{{ Layout::getSlot('content'); }}
</div>
{{ Layout::getSlot('footer'); }}
</body>
</html>
- Load up your homepage to verify it works
- Play around with the views