Re: include with variable parameters

From: Date: Fri, 23 Mar 2001 12:49:47 +0000
Subject: Re: include with variable parameters
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-406@lists.php.net to get a copy of this message
Hi, > i don't really see the need of passing a "variable parameter" to the > included template file. the template variables are also available > within the scope of the included file, so why renaming? i replied to you privately and said that i am dumb :)) but this was too fast, i can show you a really neat structure where i need such a behavior. You all know loops like this: while($row = mysql_fetch_array($res)){ $table1->append("td",$row); } this would result in templates like: <tr> {section name=inhalt1 loop=$td} <td>{$inhalt1/td.fieldname_1}</td> <td>{$inhalt1/td.fieldname_2}</td> <td>{$inhalt1/td.fieldname_3}</td> [..] </tr> {/section} -- what i want to do, is to abstract table structures in such a way: {include file="tableheader2cols.tpl" row1="header1" row2="header2"} {section name=inhalt1 loop=$td} {include file="tablecontent2cols" row1="{$inhalt1/td.fieldname_1}" row2="{$inhalt1/td.fieldname_2}"} {/section} {include file="tablefooter.tpl" row1="header1" row2="header2"} The neat thing is, that in my 2 main abstract table templates (tableheaderXcols, tablecontentXcols), i can define my tables, and in all application which are based on this tables. tablecontent2cols would look like this: <tr> <td>{$row1}</td> <td>{$row2}</td> </tr> So i need the variable parameter passing in include, otherwise i have to code the following style in php: while($row = mysql_fetch_array($res)){ $table1->assign("row1",$row["fieldname"]); $table1->assign("row2",$row["fieldname"]); } this is ok for two columns, but for 10 its horrable. The advantage is clear. My application has about 100 screens, mostly with tables, now when i want to change something on my tables, say another background (this could be done else i know) or a few design <td></td> without any meaning to my data, this is the only way to do it. Otherwise you must change all your 100 screens in some way. Long mail i know, but perhaps you get the point, this feature would be very nice for various situations... But it seems not easy to implement, because it breaks the parsing rules... ----------------------- Marc Logemann Morelogs GmbH & Co. KG Chief Software Architect ----------------------- Besuchen Sie uns auf der Cebit 2001 Halle 6 Stand C32

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