[eluser]rochellecanale14[/eluser]
Hello guys just need a little help here.
I have a difficulty in accessing smarty function in my template. Here's my sample code.
Controller:
Code:
class Category_Controller extends CI_Controller{
public function __construct(){
parent::__Construct();
}
public function index(){
$title = "Welcome to my page!";
$category = $this->category_model->getAllCategory();
$category_data = $category->result_array();
$this->smartylib->assign('category',$category_data);
$this->smartylib->assign('title',$title);
$this->smartylib->display('index.tpl');
}
}
My Template
Code:
<html>
<head>
<title>{$title}</title>
</head>
<body>
<table>
<tr>
<td>SALES CATEGORY ID</td>
<td>SALES CATEGORY NAME</td>
<td>SALES CATEGORY DESCRIPTION</td>
<td>COUNT</td>
</tr>
<tr>
{assign var = x value = ''}
{assign var = y value = ''}
{foreach $category as $x}
<tr>
<td>{$x['salescatid']}</td>
<td>{$x['salescatname']}</td>
<td>{$x['salescatdesc']}</td>
<td>{$x['salescatname'] | count_characters}</td>
</tr>
{/foreach}
</tr>
</table>
{$smarty.now |date_format:'%Y-%m-%d %H:%M:%S'}
</body>
</html>
I have a smarty error in the output. In my code I need to count the salescatname and display the output in the table also. And below. I need to post the date. But how can I access functions?
That's all thanks in advance.