December 9, 200817 yr I'm installing the smarty templating system. I'm not familiar with classes and i'm stuck at something. The configuration file has a class with variables for you to assign directory paths to, the problem i have is that i need to assign a variable to one. I'm getting the current template with an sql query. Then i'm doing this: var $template_dir = "templates/$template"; I get the error: syntax error, unexpected '"' I've read and read but i still don't understand classes Pastebin: http://pastebin.com/m6060ab95
December 10, 200817 yr Have you tried concating the string instead? try... var $template_dir = "templates/" . $template;
December 10, 200817 yr $template_dir should just be the directory of your templates, so in this case; var $template_dir = 'templates/';
December 11, 200817 yr Author How is it supposed to know which template to use then? Yes i have tried concating it.
December 12, 200817 yr In your PHP script you'll tell Smarty which template you want to use inside the template_dir directory, at the point at which you invoke it. First I'll assume you've instantiated a Smarty object (usually in a Smarty config file included in each page which uses the framework), and configured the variables in the object like this: $smarty = new Smarty(); $smarty->template_dir = '/path/to/templates/'; Then, for example, invoke the "mytmpl.tpl" template file in a script like this: $smarty->display('mytmpl.tpl'); Hope that helps!
Create an account or sign in to comment