Re: [SMARTY] start end tags patch

From: Date: Tue, 02 Jul 2002 17:04:45 +0000
Subject: Re: [SMARTY] start end tags patch
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5162@lists.php.net to get a copy of this message
FYI, You can easily accomplish this with a prefilter, no need to edit the Smarty source. WiL Laxa wrote:
This is what I did with Smarty. I have one main template file... template.htm and I have a couple of other 'layout' files that contain forms, record listing, displaying of content, etc... What I do is have '<!--capture--> <!--/capture--> tags after the <body> tag and before the </body> tag so that I can capture the contents of the layout files without the excess html headers and footers cause the main template.htm file already has those... Those layout files then become easier to edit with dreamweaver or any WYSIWYG programs because there are no missing or invalid html tags I added a function to smarty called $smarty->capture() in Smarty.class.php /*======================================================================*\
    Function:   capture()
    Purpose:    executes & captures the template results
\*======================================================================*/ function capture($tpl_file, $cache_id = null, $compile_id = null) { eregi('<!--capture-->(.*)<!--/capture-->',$this->fetch($tpl_file, $cache_id, $compile_id, false),$match); $this->clear_all_assign(); return $match[1]; } which functions like $smarty->display() except it returns the information between the <!--capture--> tags and returns it instead of displaying it. $smarty->assign('something',$something); $body = $smarty->capture('layout.htm') Then with that information I display with the main template: $smarty->assign('body',$body); $smarty->display('template.htm') and to eliminate dreamweaver from display smarty tags as broken tags when I do this <input type=checkbox name=join <!--|$join_checked|-->> because i wanted to automatically check the check box I would assign <!--|$join_checked|--> -> CHECKED, I used Mattia's Dreamweaver Smarty tags. WiL Laxa New Media Director Web: www.blendermedia.com -----Original Message----- From: Pupeno [mailto:pupeno@pupeno.com] Sent: Monday, July 01, 2002 11:52 PM To: smarty-general@lists.php.net; Monte Ohrt Subject: Re: [SMARTY] start end tags patch -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 02 July 2002 01:11, Monte Ohrt wrote:
Exactly what is this for?
I posted some time ago the way I used to work and this make it posible. The idea is to work with subtemplates, I have an index.html for all the pages so all the pages contain the same headers and layout, for example, that page includes the cascade style sheet, some javascript, everything for all the page, create som divs to show the menu, etc, etc... but the menu is not in that page because the menu is language dependant, so, the menu is in en/menu.html for example, so that page includes en/menu.html (in fact $lang/menu.html and $lang contains the language to be used). The start and end tags helps to edit that menu.html because headers are really important, Dreamweaber for example knows if it's HTML, or XHTML acording to the header, the encoding... and supouse that the menu is going to have a black background so, the font in the menu.html is white, if you don't have some enclosing formating that makes the background black, it will be imposible to work, but you can't just write put that code in the menu.html because the real formating is in the index.html, so you just put something that helps you coding outside the start and end tags and smarty won't process it, it will be ignored. I have, for example, developed a very advanced wizard engine in PHP that let's me make a wizard very fast, it uses this start and end tag because there's a wizard.html that makes the form, including the buttons at the bottom of the form, frames and that kind of things, and the diferent contents of the diferent steps are read from other files, but that other files contain forms, Dreamweaber or any good WYSIWYG editor won't allow you to insert forms object if you're not inside a form, so start and end tags solve this: <form> {start} <input type="text" /> {end} </form> you see ? I know, nobody except me depends on this feature but I think some other people may find it usefull in the future and in the worst case, it won't harm anyone, AFAIK. Thank you. - -- Pupeno: pupeno@pupeno.com http://www.pupeno.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9IU13Lr8z5XzmSDQRAie3AJ4s1aej43+sW8E1U8No9KIsQvAeEQCcCpi/ 7BOfgYLk35LDS3nMVckGKJ8= =a6zt -----END PGP SIGNATURE-----
-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.

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