Code Monkey home page Code Monkey logo

theme's Introduction

Theme support for Laravel 5

Inspired by bigecko/laravel-theme. Themes are stored inside default laravel's resources folder

For Laravel 4, please use the 1.* branch!

Installation

Require this package in your composer.json:

"yaap/theme": "2.*"

And add the ServiceProvider to the providers array in config/app.php

'YAAP\Theme\ThemeServiceProvider',

Publish config using artisan CLI (if you want to overwrite default config).

php artisan vendor:publish --tag="config"

You can register the facade in the aliases key of your config/app.php file.

'aliases' => array(
    'Theme' => 'YAAP\Theme\Facades\Theme'
)

Package config

	return array(
        'path'          => base_path('resources/themes'),
        'assets_path'   => 'assets/themes',
    );

Theme config

	return array(
        'name'         => 'default',
        'inherit' => null,
    );

##Usage

Structure

├── resources/
    └── themes/
        ├── default/
        |   ├── layouts/
            ├── partials/
            ├── views/
	        |   └── hello.blade.php
	        └── config.php

        └── admin/

    ├── views/
    |   ├── emails/
    |   |   └── notify.blade.php
    |   └── hello.blade.php
    |
    └── lang/

├── public/assets/
    └── themes/
		└── default/
			├── css/
			|	└── styles.css
			└── images/
                └── icon.png

Create theme with artisan CLI

The first time you have to create theme "default" structure, using the artisan command:

php artisan theme:create default

To delete an existing theme, use the command:

php artisan theme:destroy default

###Init theme

Theme::init($name)

This will add to views find path:

  • resources/themes/{$name}
  • resources/themes/{$name}/views

Making view

View::make('hello');
View::make('emails.notify');

Assets

Assets can be nested too. Asset url can be automatically with version.

<link rel="stylesheet" href="{{ Theme::asset('css/styles.css', null, true) }}"/>
<link rel="stylesheet" href="{{ Theme::asset('css/ie.css', null, 'v1') }}"/>

The first one will get version from filemtime, the second one - from params

###Blade templates

	@extends('layouts.master')

	@include('partials.header')

	@section('content')

	    <section id="main">
	        <h1>HOME</h1>
	    </section>
	@stop

	@include('partials.footer')

###Fallback capability

You still able to use default View::make('emails.notify') which is stored outside the themes directory

theme's People

Contributors

yaapis avatar sroutier avatar snipe avatar terion-name avatar

Watchers

James Cloos avatar dandisy avatar

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.