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

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:

  1. Add to composer.json:
"require": {
	"punn/laymode": "dev-master"
},
  1. Add 'Punn\Laymode\LaymodeServiceProvider' to the providers array in app/config/app.php (Laravel v4.*)
  2. Add 'Layout' => 'Punn\Laymode\Facades\Laymode' to the aliases array in app/config/app.php
  3. Load a random page you have to create the tables in the database
  4. Run php artisan view:publish punn/laymode in Terminal in the laravel project directory
  5. Add routes to the database
  6. Add pages matching the route id
  7. 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
  1. 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);
	}
}
  1. Point your homepage route to use LayoutController and home for action or manually LayoutController@home
  2. Make sure you have a page named 'home' pointed at the home route id (ex. '/')
  3. Create a templates folder inside the app folder
  4. Add a template named desktop.homepage to your laymodes_templates db table, don't work about json_slots (in testing)
  5. Create a desktop layout with the json encoded json_views used in the example above... template = id of the homepage template you just created
  6. Create the desktop folder inside the templates folder you created in step 11
  7. 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>
  1. Load up your homepage to verify it works
  2. Play around with the views