This project's goal is to create an easy in implementation and simple micro-enigne with blade theme support and text files based content management.
composer create-project szyminson/simple-website projectName
,.env.example
to .env
and change BASE_DIR
variable to your projects path,The best way to understand how to use Simple Website is to dig through the files while reading this README file.
Subpage list is stored in /public/content/pages.config
by default (you can change it's path in .env
file). Remember to place subpages in the config file in order you want to see them in menu. First subpage from the file is automatically treated as a home page.
Simple Website uses BladeOne templating engine. There are 3 types of templates:
Main and sub layouts are stored in /views/layouts
. Modules' layouts are stored in /views/modules
.
/views/layouts/LayoutName.blade.php
/views/modules/ModuleName.blade.php
You can use Asset Packagist for your front-end dependencies. By default front-end assets will be stored in /public/assets
.
Modules are simple parts which can be used to build your subpage. You can create 2 kinds of modules:
Just simple modules containting only html code. You can create them by creating a blade template in /views/modules
.
/views/modules/ModuleName.blade.php
In dynamic modules you can use your own php code. For this purpose you have to create a php file in /modules
as well as a blade template in /views/modules
. You can pass data from the backend part of your module to the template by setting a $Content
array.
$pageId
- it's an id of current subpage,$pages
- an object containting all info about your subpages,$blade
- you can optionally load some additional templates into the $Content
array but it's not recommended,$parsedown
- you can use this object to parse some markdown into html.
/modules/ModuleName.php
/views/modules/ModuleName.blade.php
<?php
$VariableName = "Your data";
$VariableName2 = "Some other data";
$VariableName3 = array("one", "two", "three");
$Content = array("Example" => $VariableName, "Example2" => $VariableName2, "Items" => $VariableName3);
?>
<p>
{{ $Example }}
</p>
<p>
{{ $Example2 }}
</p>
<ul>
@foreach($Items as $Item)
<li>$Item</li>
@endforeach
</ul>
Components are modules which can be placed in your main or sublayout ( for example Menu ). To use a module as a component you have to put it's name into a components' config file ( by default /public/content/components.config
). Then you can simply load the component into your layout file by using it's name: {{ $Menu }}
.