Download the PHP package ikkez/f3-template-sections without Composer
On this page you can find all versions of the php package ikkez/f3-template-sections. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package f3-template-sections
Template sections
This addon introduces template inheritance via sections for the F3 template engine.
Install
To install with composer, just run composer require ikkez/f3-template-sections
.
In case you do not use composer, add the src/
folder to your AUTOLOAD
path or copy the files from src/
into your libs.
Initialize
To use the new directives, you need to register them:
Init:
Usage
Imagine this main site template:
You see we have create a section with id=sidebar
. This section can contain default content already if you want,
but within article.html
you can now inject content to the sidebar, which is actually in a parent level:
That's basically it. There are some more modes for injecting content:
Append / Prepend
In this example we have a breadcrumb navigation. You can change the generated tag-element with the tag
-attribute.
By default the content in the section is replaced upon inject. If you wish, you just append the existing content like this:
You can also use prepend
as inject mode.
Rendering locally
You can switch the model to use local variables instead of rendering the content in the injected section. This is useful when you iterate over an array of data within a <repeat>
block.
API
section
Attributes:
section
Used to identify the new section.id
Alias tosection
, but theid
attribute will be visible in the final markup.tag
The tag-element name of the final section. Default:section
.
When you settag="FALSE"
, the section content is not wrapped into any element.
Any other attributes are just passed to the final tag element.
inject
Attributes:
section
Used to identify the destination section.id
Alias tosection
.mode
The injection mode for content:
overwrite (default): replaces the existing content in the section
append: adds content after the existing content
prepend: adds content before the existing contentlocal
Render element locally with existing variables first
Licence
GPLv3