https://github.com/tattersoftware/codeigniter4-layouts
Layout management service for CodeIgniter 4
https://github.com/tattersoftware/codeigniter4-layouts
Last synced: about 1 year ago
JSON representation
Layout management service for CodeIgniter 4
- Host: GitHub
- URL: https://github.com/tattersoftware/codeigniter4-layouts
- Owner: tattersoftware
- License: mit
- Created: 2021-11-28T21:09:48.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-01-18T16:28:52.000Z (over 2 years ago)
- Last Synced: 2025-04-10T04:41:01.285Z (about 1 year ago)
- Language: PHP
- Size: 45.9 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Tatter\Layouts
Layout management service for CodeIgniter 4
[](https://github.com/tattersoftware/codeigniter4-layouts/actions/workflows/test.yml)
[](https://github.com/tattersoftware/codeigniter4-layouts/actions/workflows/analyze.yml)
[](https://github.com/tattersoftware/codeigniter4-layouts/actions/workflows/inspect.yml)
[](https://coveralls.io/github/tattersoftware/codeigniter4-layouts?branch=develop)
## Description
This library provides a commons means of managing [View Layouts](https://codeigniter.com/user_guide/outgoing/view_layouts.html)
across package modules and applications.
## Installation
Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities
and always be up-to-date:
* `> composer require tatter/layouts`
Or, install manually by downloading the source files and adding the directory to
`app/Config/Autoload.php`.
## Configuration
The code of `Layouts` amounts to a single config file: `Tatter\Layouts\Config\Layouts`. This
file provides the path for each layout as a property. Initially the config file only
includes a single property: "default". By supplying your own path via an `App` config file
you can direct any package or module using `Layouts` to use your layout instead. For example,
**app/Config/Layouts.php**:
```php
extend(config('Layouts')->default) ?>
= $this->section('main') ?>
Hellow world!
= $this->endSection() ?>
```
You can use any layout name you have configured, and any name that does not match will fall
back on the path supplied for "default".
> See the CodeIgniter User Guide to read more on [View Layouts](https://codeigniter.com/user_guide/outgoing/view_layouts.html)
## Layout Expectations
For consistency this library assumes that the "default" template will have the following sections:
* **headerAssets**: The last section prior to the closing `` tag, available for adding CSS tags and the like.
* **navbar**: A navigation menu, typically to be displayed along the top of the page.
* **main**: The main content for the page (can include nested views, etc).
* **footerASsets**: The last section prior to the closing `