GitXplorerGitXplorer
a

laravel-view-themes

public
15 stars
3 forks
0 issues

Commits

List of commits on branch master.
Unverified
bbcfdcfbbcc5e905745bfe5f440b99384b28f0cd

Remove PHP 5.3 from Travis build

aalexwhitman committed 10 years ago
Unverified
90e2ab19ce290a9d58dbd516d199e375b3b05e93

Update README

aalexwhitman committed 10 years ago
Unverified
71f86011ea7ad12b8e19bfb6126f7032b1642fc6

Update for Laravel 4.2

aalexwhitman committed 10 years ago
Unverified
9ec676d7f450d81355f1637052a71fce2b643e94

Update README

aalexwhitman committed 10 years ago
Unverified
d2d5dfa29d8ae78a6e5196e274484f31502ea168

Add function to get current theme path

aalexwhitman committed 10 years ago
Unverified
4e26fd544a39b66faceb40cedcfc6daede2d3659

Clear previous paths on initialise

aalexwhitman committed 10 years ago

README

The README file for this repository.

Laravel View Themes

View themes is a simple package to provide themed view support to Laravel.

Installation

Add alexwhitman/view-themes to the require section of your composer.json file.

"alexwhitman/view-themes": "1.2.x"

Run composer update to install the latest version.

Setup

This package extends Laravels built in ViewServiceProvider, so that provider must be replaced in app/config/app.php. Replace the instance of 'Illuminate\View\ViewServiceProvider', with 'AlexWhitman\ViewThemes\ViewThemesServiceProvider',.

Configuration

The default settings are for the themes to be in a themes directory in app/ with the default theme called default.

app/
    themes/
        default/
            views/

To change these defaults the package config will need to be published with artisan config:publish alexwhitman/view-themes. The new config file, app/config/packages/alexwhitman/view-themes/config.php, can then be customised as required.

Usage

A standard call to View::make('index') will look for an index view in app/themes/default/views/. However, if a theme is specified with $app['view.finder']->setCurrentTheme('my-theme'); prior to calling View::make() then the view will first be looked for in app/themes/my-theme/views. If the view is not found for the current theme the default theme will then be searched.

Facade

The ViewTheme facade can also be used if preferred ViewTheme::setCurrentTheme('my-theme') by adding an entry for AlexWhitman\ViewThemes\ThemeFacade to app/config/app.php.

Example

Given a directory structure of

app/
    themes/
        default/
            views/
                layout.blade.php
                admin.blade.php
        my-theme/
            views/
                layout.blade.php
View::make('layout'); // Loads app/themes/default/views/layout.blade.php

$app['view.finder']->setCurrentTheme('my-theme');

View::make('layout'); // Loads app/themes/my-theme/views/layout.blade.php
View::make('admin'); // Loads app/themes/default/views/layout.blade.php

Changelog

1.2.0

  • Update for Laravel 4.2

1.1.2

  • Add function to get current theme path

1.1.1

  • Clear previous paths on initialise

1.1.0

  • Update for Laravel 4.1

1.0.0

  • Initial release