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


Latest Comments

  • Guest on Forum
    “noFollow links.” - Jun 19
  • username on Forum
    “Sponsor or Premium user” - Jun 14
  • on Forum
    “Template https://www.website.com/skins/_common/section.tpl not found! contact webmaster” - Feb 24
  • admin on 01. Administration Panel
    “Untitled” - Jan 24
  • on 01. Administration Panel
    “Can't Login to Admin” - Jan 23

Most Commented

Online Users

There are 151 users online.


Connect with us on Facebook


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