8. Working with BEGINSECTION

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


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

  • HTML CODE can be html tags, including tpl vars, BEGINIF & BEGINBLOCK!
  • Put the BEGINSECTION lines in a separate file, eg in section.tpl


In section.tpl

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

In test.tpl

<p>Welcome to test page!</p>
<h1>Test 1</h1>

<h1>Test 2</h1>

In test.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 ();


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?

More Comments/Post Your Own


Online Users

There are 8 users online.


Connect with us on Facebook


Subscribe to our newsletter for the latest updates and exciting promotions!