Smarty,子目录中的页面

i am trying to figure out how to hold pages in subdirectories (categories) using php Smarty template engine.

For instance if my structure is:

index.php
category1/page1.php
category2/page2.php

etc.

the root index.php is rendering just fine

using the default smarty setup:

<?php 
require_once('lib/smtemplate.php');

$data = array(
    'meta_keywords' =>'key1, key2',
    'category' =>'category1'
    );

$tpl = new SMTemplate();
$tpl->render('page', $data);

?>

but if i copy it into subdirectory it breaks even if i change to

require_once('../lib/smtemplate.php');

and i cant find a solution so far.

Appreciate your help. thx.

Define a basepath:

define("BASEPATH", "/var/www/yoursite/");

And include like this:

require_once(BASEPATH.'lib/smtemplate.php');