print

8. Working with BEGINSECTION

You are here: C97net3. Developer's Guide

How to use BEGINSECTION with tpl

BEGINSECTION can be used to simplify your tpl files, where the BEGINIF & BEGINBLOCK can't be used.

Usage

<!-- BEGINSECTION section_name -->HTML CODE<!-- ENDSECTION -->

Sample

In section.tpl

<!-- BEGINSECTION justtest -->
<p>This is just a test <b>{$i}</b></p>
<!-- ENDSECTION -->

In test.tpl

<p>Welcome to test page!</p>
<h1>Test 1</h1>
{$testvar}

<h1>Test 2</h1>
{$testvar2}

In test.php

<?php
require './includes/user_init.php';

// load the required section (in section.tpl)
load_section ('section.tpl');

// now load the output tpl
$tpl = load_tpl ('test.tpl');

// then create the sample data
$txt['i'] = 'First';
$txt['testvar1'] = quick_tpl ($tpl_section['justtest'], $txt);

$txt['i'] = 'Second';
$txt['testvar2'] = quick_tpl ($tpl_section['justtest'], $txt);

// output
$txt['main_body'] = quick_tpl ($tpl, $txt);
flush_tpl ();
?>

Notes

SECTION usually used to create a design consistency across the web. You can see a better (and more complex) sample in Kemana Directory. It's using SECTION for links list design, and keeping the design the same in list.php & search.php.


There is no comment. Why not be the first?

read more More Comments/Post Your Own

Account

Search

Tags

acp add all also any create default display don download easy echo etc features field file files folder form function includes information init kemana link list may module name need number own page php please qengine read require script set site skin time tpl url use user using version welcome