Re: [SMARTY] Assign a template to a variable....

From: Date: Mon, 27 May 2002 19:42:39 +0000
Subject: Re: [SMARTY] Assign a template to a variable....
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4407@lists.php.net to get a copy of this message
OK, sorry I didn't answer your questions. However, if designers are using {section} then they are looking at the HTML, if they're doing that then if statements are only a five-minute chat away. With all the template systems the only feature that can really be made use of by a non-technical designer is the variable substitution, anything else needs knowledge of HTML structure, both on the way in to Smarty and the way out. I think you're exaggerating a bit when you say people who use tags are l33t. If they're designing templates that will need forms sometimes then they understand HTML. Anyway, my point is that the alternative is not exactly simple (although it is simpler): {include file="form.tpl"} form.tpl contains the if statement: {if $form ne ""} <table><tr><td> <form> <input name="blah"> </form> </td></tr></table> {else} &nbsp; {/if} form.tpl is yours and the designers don't touch it, which makes it easier, but they will need to add the include magic: The way around this would be to use {capture} to assign the output from form.tpl into a variable called $formblock or something. You would need to include the template designed by your designers from some template of your own which includes and captures form.tpl. Instead of using a top-level developer's template you could also capture the output of form.tpl using Smarty's fetch method, which will return the output instead of dumping it to the browser. Ben Godfrey On Monday, May 27, 2002, at 07:56 PM, Gandalf wrote:
I have a policy in using conditions inside a template, my templates should be containing NOTHING else then HTML and whatever needs to be displayed inside {}. That is it. The second i implement logic into a template, the purpose is lost. The one and only reason why i started to use templates is because i want to completely strip any html out of my code, and of course the other way around as well. I mean, hey, what's the point using {if $arg=$val} show this {else} show that {/if} I could as well do it in my code! No, the only thing to be in a template IMHO is {$whatever} and the {section} {/section} . But that's it. Also, i do not want a template that contains differently, i want a template inside a template, and that template is only to be shown when the template variable is true, the decision whether it will be true or not has nothing to do in a template. Also, another thing, maybe you have the time to provide your designers with tutorials about templates, but we for sure do not have the time. Why do you think we want to use templates in the first place? To let the designers do there work and we can do ours. The only thing my designers have to do, is designing, nothing else.We know what the site will look like, they start to design and put {$whatever} in those placed where input that they cannot control or that needs to be looped in there HTML code. Before that we write a Guideline (as in every larger project) with naming conventions etc.. so we all know what were doing. Now you come along trying to tell me i have a policy against conditionals? Don't think so. Please note, im not saying that those functions provided by Smarty aren't usefull. I can imagine they come in very handy if you are working on a project on your own, cause then you know your code and thus also know where you could put conditionals in the template. Another note: This statement of yours Any template designer who understands that web pages are code and not just DW buttons should be able to use it easily. ..is bullex. What you think? That we are some script kiddies trying to create a l33t looking PHPNuke with 10 different designs? A template system in the first place is to strip design from code. Point. The rest is plain neat stuff. Last thing, i asked two question, none of those questions where answered by you, you also asked me to explain my situation, which i did. Are you going to answer my questions now or do you want to keep babbling? Jürgen Hauser At 19:28 27.05.02 +0100, you wrote: So you want a template that behaves differently under different conditions but you have a policy against using conditionals? Why can't a "template" contain an if statement. Any template designer who understands that web pages are code and not just DW buttons should be able to use it easily. A non-conditional alternative (if one could be written) would always be much more complicated because it would be a hack around the language features. If you provide good tutorials with examples of how if statements work then people will learn. If this isn't the reason why you don't want if statements then tell us a bit more about your situation. Ben Godfrey On Monday, May 27, 2002, at 07:12 PM, Gandalf wrote: Hello! I have been trying to find out how to do this for nearly half a day now, but i failed. Let's say i have a file called index.tpl. And i also have a file which contains a form called form.tpl. Now i want the form to be in my index.tpl so index.tpl would look like this: <html> blah blah <table blah blah> <tr> <td> {$form}</td> <tr> </table> ..... And i do not want the form to be displayed all the time, rather i want the form to be shown only if $form is TRUE, else it should display a nonbreakingspace (&nbsp;). So my two questions are: How can i display a template inside a template and also how can i tell the template index.tpl to show either the form or a nonbreakingspace WITHOUT having to use smarty's {if} {else} etc.. functions (cause the second i have to do that, it is IMHO not a template anymore, no offence taken). I downloaded the docu as a .pdf file and looked through it what seemed to be forever, but either i totally overlooked it, or what i want is not possible, which i dought very much :) Any help or tips, hints would be appreciated. Thanks a lot in advance! Best regards from Vienna, Jürgen Hauser Jürgen (aka. Frodo the scribe ====================== Visit the MECCG Forums at http://www.coen.at.tf -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Jürgen (aka. Frodo the scribe ====================== Visit the MECCG Forums at http://www.coen.at.tf


« previous php.smarty.general (#4407) next »