<< Click to Display Table of Contents >> Navigation: First Steps > Templates |
A template means in German "template" or "document template".
A template is basically a source code template that is copied and modified for the project.
A template consists of several template pages. Each page can:
Be a directory, this directory will be copied with all subdirectories. There is no processing.
A static page or file (only copied, no processing)
A project page (for example, index.php, login.php, etc., a page that only appears once in the project! Each project page is processed!)
A table page (each database table is copied and processed 1x per table)
Of course, each project page or table page can be processed per language.
Technical information about the templates:
All templates are "compiled" and translated into the desired source code. If you've ever worked with PHP smarty, you'll understand the system and the procedure, if not, I'll explain it very carefully:
All templates can be changed by you, each file is in the source code, this is always recompiled after a change before generation.
Let's look at a template page: (read.php)
<?php
require 'database.php';
$id = null;
if ( !empty($_GET['id'])) {
$id = $_REQUEST['id'];
}
if ( null==$id ) {
header("Location: table_{filename}.php");
} else {
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM {filename} where {fileprimarykey} = ?";
$q = $pdo->prepare($sql);
$q->execute(array($id));
$data = $q->fetch(PDO::FETCH_ASSOC);
Database::disconnect();
}
?>
<?php
include_once('header.php');
?>
<body>
<div class="container">
<?php
include_once('navbar.php');
makenavbar("index");
?>
<div class="jumbotron">
<h1>{filedescription}</h1>
<div class="form-horizontal" >
{for {nmaxitems}}
<div class="control-group">
<label class="control-label">{item.caption}</label>
<div class="controls">
<label class="checkbox">
<?php echo $data['{item.name}'];?>
</label>
</div>
</div>
{endfor}
<div class="form-actions">
<a class="btn" href="table_{filename}.php">Zurück</a>
</div>
</div>
</div>
</div> <!-- /container -->
<?php
include_once('footer.php');
We have made the Scoriet template variables and the Qellcode control for you RED and slightly bigger.
{filename} is the filename
{fileprimarykey} is the primary key
{filedescription} is the file name
{for {nmaxitems}} / {endfor} is a for / next loop that traverses all fields within the file. nmaxitems is the variable for all database fields.
{item.name} is within the for / while loop the current database field.
This may be a bit confusing, but each template is built exactly the same and each template can be changed the same way.
a full list of keywords you find in Cheat Sheet