Is possible to display the returned result of a function of an object with smarty.
Here is the code I am trying to write.
index.tpl
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- machid: 289 -->
<head>
<title>{$title}
<link href="templates/stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<div id="container">
<div id="header">
{$ee->ss}
</div>
<div id="content">
{$Catshow->showCat}
</div>
</div>
class.cls.php
<?php
require("includes/config.inc.php");
class Database{
public $CatArray;
private $conn;
public function __construct(){
global $config;
$host= $config['db']['host'];
$user = $config['db']['user'] = "root";;
$pass = $config['db']['pass'] = "";
$this->conn= new PDO($host,$user,$pass);
}
public function showCat(){
$query = $this->conn->query("select * from frm_categories");
while($result = $query->fetch(PDO::FETCH_ASSOC)){
return $result['name'];
}
}
}
?>
Here the object returns the result of categories.Namely Music, Video and so on.
index.php
<?php
require("libs/Smarty.class.php");
require("classes/db.cls.php");
$showDbCat = new Database;
$showDbCat->showCat();
echo $showDbCat->catArray;
$smarty = new smarty;
$smarty->assign(Catshow,$showDbCat);
$smarty->display("index.tpl");
?>
as I assign the result into smarty variable.Nothing would be displayed.
I hope you understand my question because of bad english.