szyminson/simple-website

This package is abandoned and no longer maintained. No replacement package was suggested.

A simple micro-framework for simple websites.

v0.1.0 2018-12-02 20:31 UTC

This package is auto-updated.

Last update: 2022-01-10 18:40:49 UTC


README

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.

Table of Contents

Dependencies

Installation

  1. composer create-project szyminson/simple-website projectName,
  2. Rename .env.example to .env and change BASE_DIR variable to your projects path,
  3. Open your project in a browser and you should see an example page.

Advice

The best way to understand how to use Simple Website is to dig through the files while reading this README file.

Subpages

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.

Layout

Simple Website uses BladeOne templating engine. There are 3 types of templates:

  • Main Layout - a main part of your website's look, it's extended by sublayouts,
  • Sublayout - this is a layout that is used by subpages, it extends main layouts,
  • Module's layout - each module has it's own layout so you can easily change a look of the module.

Main and sub layouts are stored in /views/layouts. Modules' layouts are stored in /views/modules.

File naming

  • Main and sub layouts: /views/layouts/LayoutName.blade.php
  • Modules' layouts: /views/modules/ModuleName.blade.php
Note

You can use Asset Packagist for your front-end dependencies. By default front-end assets will be stored in /public/assets.

Modules

Modules are simple parts which can be used to build your subpage. You can create 2 kinds of modules:

Static Modules

Just simple modules containting only html code. You can create them by creating a blade template in /views/modules.

File naming

/views/modules/ModuleName.blade.php

Dynamic Modules

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.

Variables available in module's backend

  • $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.

File naming

  • Backend: /modules/ModuleName.php
  • Frontend: /views/modules/ModuleName.blade.php

ExampleModule.php

<?php
$VariableName = "Your data";
$VariableName2 = "Some other data";
$VariableName3 = array("one", "two", "three");
$Content = array("Example" => $VariableName, "Example2" => $VariableName2, "Items" => $VariableName3);
?>

ExampleModule.blade.php

<p>
  {{ $Example }}
</p>
<p>
  {{ $Example2 }}
</p>
<ul>
  @foreach($Items as $Item)
  <li>$Item</li>
  @endforeach
</ul>

Components

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 }}.