Re: [htmltmpl] how to determine if tmpl_var exists in a loop?
Brought to you by:
samtregar
From: petersm <pe...@ve...> - 2004-04-17 16:38:34
|
Puneet Kishor <pk...@ei...> > > I am curious too... I've been using H-T for about a year and a half, > and I've never had to query the template. My assumption is that params > in the template are assigned by me, so I would automatically know what > vars exist in the template. > > What is/are a typical circumstance(s) where I would not already know > what vars exist in a template and would want to use query to find out? > > Thanks. Querying the template allows you to be able to create another layer of abstraction between the code and the template. We use it to create a custom 'TemplateLoader' that will look at a given template, and by the naming convention that we use on the vars and loops it will actually create the SQL statements, query the database and load the templates. The only thing we have to remember is to use the nameing convention for the vars. This works for about 95% of the occassions that we use H::T and then the other %5 we use it more straight forward. The benefits of this are that if we want to add some more data to the template (an extra column or field or something) we just add the correct TMPL_VAR to the template and then the TemplateLoader does the rest. We don't have to change the code. If you're curiosity is piqued, then you can check out how we do this at cheesepizza.venzia.com. The module in question is named 'CheesePizza::TemplateLoader'. Michael Peters Venzia |