devjs11
devjs11

Reputation: 1948

Smarty, pages in subdirectories

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.

Upvotes: 1

Views: 2524

Answers (1)

Nanne
Nanne

Reputation: 64409

Define a basepath:

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

And include like this:

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

Upvotes: 2

Related Questions