Package Data | |
---|---|
Maintainer Username: | Siipis |
Maintainer Contact: | siipis@live.co.uk (Amalia Surakka) |
Package Create Date: | 2016-03-24 |
Package Last Update: | 2017-04-16 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:17:18 |
Package Statistics | |
---|---|
Total Downloads: | 26 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Content Management System built on Twig and Laravel
Install using composer require siipis/cms
Template caching causes problems with page configuration. You can either regularly clear the cache by running the console command twig:clean
or by disabling the cache altogether.
Set 'cache' => false,
in the twigbridge.php
config file to disable caching.
Add the following lines in the app.php
config file:
Providers:
Siipis\CMS\ServiceProvider::class,
Aliases:
'Twig' => TwigBridge\Facade\Twig::class,
'YAML' => Symfony\Component\Yaml\Yaml::class,
'CMS' => Siipis\CMS\Facade\CMS::class,
'CMS_Helper'=> Siipis\CMS\Facade\Scaffolding::class,
'CMS_Parser'=> Siipis\CMS\Facade\Parser::class,
Add at the end of the routes.php
file
/*
* Catch-all route for views
*/
Route::get('{route}', function ($route) {
return CMS::view($route);
})->where('route', '.*');
Add a twig file under resources/views/pages
to serve the view without a controller in between.
CMS views can be served through the CMS facade using CMS::view('page')
. Note that paths are relative to the pages directory.
Place the following directories directly under the template root (default resources/views
)
Used in layout files for indicating where the page is placed in the layout.
Placeholder tag for the page title.
The following helper tags are included to clean up the syntax. All paths are relative to the include type.
The pagecontains an optional config section in the beginning of the file. The divider is ===
.
Typical layout file:
title: Welcome
layout: default
with:
- world: "Twig"
data:
- users:all
===
Hello {{ world }}
<br />
{% for user in users %}
<p>{{ user.name }}</p>
{% endfor %}
title
: Page title, appended using {% title %}layout
: Name of a file in the layout directory, with or without the .twig extensionwith
: Key value attributes to be sent to the pagedata
: Data provider accessorData providers extend the CMS\DataProvider
class and can be used to serve data without a controller.
Use php artisan make:data ProviderName
to create a new data provider. By default data providers are located in the app/CMS/Data
directory.
Data providers must implement three methods:
getAccessor
: name of the accessor called by the config, e.g. 'users'dataAll()
: returns all entries, called with <accessor>:all
dataOne($id)
: returns a single entry, called with <accessor>:one[1]
Additional methods can be created by additional methods.
The data is automatically sent to the view and can be accessed by the accessor name, e.g. {{ users }}
. If users:one[1]
was called, the accessor is in singular, i.e. user
.
Accessor methods accept the following pseudo numbers (example: users:one[#auth]):
#auth
: returns the id of the authenticated user, or null if no login exists#url
: returns the last url query, e.g. http://example.com/foo/bar
returns bar
The pseudo numbers are defined in CMS\Parser\DataParser.php
.