PHP Classes

File: examples/user_loop.php

Recommend this page to a friend!
  Classes of Michael Orji   Simplate   examples/user_loop.php   Download  
File: examples/user_loop.php
Role: Example script
Content type: text/plain
Description: example usage
Class: Simplate
Template engine that replaces arrays of variables
Author: By
Last change:
Date: 10 years ago
Size: 1,161 bytes
 

Contents

Class file image Download
<?php

include('../simplate.class.php');
   
/**
* Creates a new template for the user's profile.
* Fills it with mockup data just for testing.
*/
$data = array('username'=>'Kingslayer', 'image_url'=>'images/koala.jpg', 'firstname'=>'Jamie', 'lastname'=>'Lanister', 'email'=>'kslayer@thelanisters.com');
$user_tpl = new Simplate('templates/', 'user_profile_loop.tpl');
$user_tpl->user_data = $data;
   
/**
* Loads our layout template, settings its title and content.
*/
$main_tpl = new Simplate('templates/', 'layout.tpl');

$main_tpl->content = $user_tpl->parse();

/**
* In this case, set the title after the call to the parse() method
* This is because the properties of the $user_tpl object will
* only be created after the parse() method has been called to set the member properties of the Simplate Instance
* from the members of the data array
*
* If title or any other property (apart from the data associative array) is set before the call to parst(), you will get an empty string
*/
$main_tpl->title = $user_tpl->username. '\'s profile';
   
/**
* Outputs the page with the user's profile.
*/
echo $main_tpl->parse();
   
?>