A simple CMS, which requires no database. All data are stored in twig and json files.
Demo: cms.cinquiemecrayon.eu
- Clone or download the CMS source.
- Run composer to download dependencies.
- Change file name
_install.dist
to_install.php
- Run
yarn
. - Generate assets:
- Develop
npm run dev
- Production
npm run prod
- Develop
- Go to Back Office (
yourdomain/_bo
) and change admin password. - Configure site (
yourdomain/_bo/settings.php
).
Crayon CMS uses the altorouter routing class.
| function | variable | example |
|--------------|----------------|------------------------|
| articlesList | [i:page]? | blog/[i:page]?/ |
| article | [slug:article] | blog/[slug:article] |
Variables of the path are passed to the controller in the $dp
array.
Variables are divided by |
character. They are passed to the controller in the $sp
array.
| function | 1st variable | 2nd variable |
|----------|---------------|--------------|
| page | alias of page | - |
| contact | menu name | - |
| function | 1st variable | 2nd variable |
|--------------|------------------------------|--------------|
| articlesList | id of category (0 for all | menu name |
| | categories assigned to menu) | |
| article | - | - |
Site main directory.
Array with created routes.
Examples:
Generate link:
<a href="{{ root~routes['home'].path }}">{{ routes['home'].name }}</a>
Array with site settings.
Examples:
<title>{{ settings['site_name'] }}</title>
You can create your own twig templates by overloading the base template.
Place your files in /views/_templates/{name of template}
directory.
The directory structure should be the same as the main view directory.
Example:
/views/_templates/new_template/base.html.twig
/views/_templates/new_template/blog/article.html.twig
The folder name with the new template appears in the settings.
You can use the twig global variable t
for rendering strings.
Example:
<p>{{ t.message }}</p>
Add this line:
<scipt src="{{ root }}/js/translation.js?lang={{ menu.lang }}"></script>
to your template for generate an js global object with current language's translations. You can use this object in your js. Exaple:
alert(translate.thank_you);
You can create new users in admin panel.
To give the user permission to edit content in the admin panel
you need to add the appropriate permissions in data/users.json
file.
Example:
{
"123": {
"role": "",
"pwd": "password",
"permissions": [
"pages",
"files",
"files.manager",
"files.uploader",
"file.upload",
"file.remove",
"gallery",
"gallery.items"
]
}
}
Permission names are filenames in the _bo
directory.