PHP code example of phpffcms / ffcms-templex

1. Go to this page and download the library: Download phpffcms/ffcms-templex library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phpffcms / ffcms-templex example snippets


$loader = alize template engine
$tpl = new \Ffcms\Templex\Engine(__DIR__ . '/tpl');
// load default ffcms html helpers as extensions
$tpl->loadDefaultExtensions();

// render /tpl/block.body.php example
echo $tpl->render('block/body', ['test' => 'some value']);

$this->layout('path/to/file', ['var' => 'value']);


$this->layout('layout', ['title' => 'My first title']);

<doctype html>
<html lang="en">
<head>
    <title><?= $title 

echo $this->listing('ul')
    ->li('item 1')
    ...
    ->li('item n')
    ->display()

$listing = $this->listing('ul');

for ($i = 0; $i < 100; $i++) {
    $listing->li('Item #' . $i);
}

echo $listing->display();

echo $this->listing('ul', ['class' => 'my-listing'])
    ->li('Text item')
    ->li(['text' => 'Google link', 'link' => ['https://google.com']])
    ->li(['text' => 'Local link', 'link' => ['controller/action', ['id' => 1]], 'properties' => ['class' => 'li-item']])
    ->display();

echo $this->table(['class' => 'table'])
    ->head(['class' => 'table-header'], [
        ['text' => 'column1'],
        ['text' => 'column2'],
        ['text' => 'column3'],
    ])
    ->row([
        ['text' => 'row 1, <strong>column1</strong>', 'html' => true], // html allowed
        ['text' => 'row 1, column2', 'properties' => ['class' => 'alert alert-danger']],
        ['text' => 'row 1, column3']
    ])
    ->row([
        ['text' => 'row 2, column1'],
        ['text' => 'row 2, <em>column2</em>'], // html not allowed!
        ['text' => 'row 2, column3'],
        'properties' => ['class' => 'alert alert-success']
    ])
    ->display();

$this->table([properties])
    ->selectize(index, name)

$this->table([properties])
    ->sortable([
        0 => 'getname' // will build ?getname=1 and ?getname=2 links as asc/desc sorting query
    ])
/tpl/block/body.php
/tpl/layout.php
layout.php
$this->listing('type', [properties])

// inline call:
echo $this->table([properties])
    ->head([properties], [titles])
    ->row([items1])
    ->row([items2])
    ->display();
    
 // named call:
$table = $this->table([properties]);
$table->head([properties], [titles])
for ($i = 0; $i < 100; $i++) {
    $table->row([elements]);
}
echo $table->display();