You are here: C97net • 3. 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?