I've been coding a product with xtemplate. It is of MVC Architecture. I've an index file which has its own xtemplate output.
In the index file, I would also like to put the view of various modules which would have different xtemplate output according to their view php logic.
Now I would like to include one php view files to one index file. Each of the view files has its own blocks inside and would display a grid of data. Now including the file has been tough. Here is the code that I'm trying to work with
PHP code
Code: Select all
require_once(APP_FOLDER."/themes/".$theme."/header.php");
require_once(APP_FOLDER."/themes/".$theme."/left.php");
$xtpl = new Xtemplate(TPL_DIR."clients/index.xtpl");
require_once(APP_FOLDER."/modules/clients/view.php");
$xtpl->parse('main');
$xtpl->out('main');
//require_once(APP_FOLDER."/modules/clients/view.php");
require_once(APP_FOLDER."/themes/".$theme."/footer.php");
?>
index.xtpl
Code: Select all
<!-- BEGIN: main -->
<div id="content_box">
<div id="content">
<div id="clientsView">
<p align="right" style="padding-right:10px;"><input id="addClient" type="button" value="Add Client" onclick=window.location="index.php?ad=clients&af=add"></p>
{FILE "views/clients/view.xtpl"}
</div>
</div>
</div>
</div>
<!-- END: main -->
Code: Select all
<!-- BEGIN: main -->
<div>
<!-- BEGIN: row -->
<table class="clientsView" border="0" cellpadding="0" cellspacing="1">
<tr><th>Client Name</th><th>Email</th><th>Phone</th><th>Web</th><th>Action</th>
</tr>
<!-- BEGIN: columns -->
<tr>
<td>{DATA.NAME}</td><td>{DATA.EMAIL}</td><td>{DATA.PHONE}</td><td>{DATA.WEB}</td><td>Edit/Delete</td>
</tr>
<!-- END: columns -->
</table>
<!-- END: row -->
</div>
<!-- END: main -->
the view.php code is below
Code: Select all
require_once(APP_FOLDER."/models/Client.php");
$client = new Client($db);
$clients_list = $client->getClients();
//print_r($clients_list);
$xtpl = new Xtemplate(TPL_DIR."clients/view.xtpl");
foreach($clients_list as $clients ){
$clients_data = array(
"ID"=>$clients['client_id'],
"NAME"=>$clients['client_name'],
"EMAIL"=>$clients['email'],
"PHONE"=>$clients['phone'],
"WEB"=>$clients['web'],
);
$xtpl->assign('DATA',$clients_data);
//$xtpl->assign('ROW_NR', $i);
$xtpl->parse('main.row.columns');
}
$xtpl->parse('main.row');
$xtpl->parse('main');
$xtpl->out('main');