setTemplateDir('views/'); // assign variables to the template $smarty->assign('pageTitle', 'Homepage'); // fetch the pageTitle variable $pageTitle = $smarty->get_template_vars('pageTitle'); // set the HTML page title $htmlTitle = '' . $pageTitle . ' '; echo $htmlTitle;
setTemplateDir('views/'); // assign variables to the template $smarty->assign('products', [ ['name' => 'Product 1', 'price' => 20], ['name' => 'Product 2', 'price' => 30], ['name' => 'Product 3', 'price' => 40], ]); // fetch the products variable $products = $smarty->get_template_vars('products'); // display a list of products echo '