Re: [SMARTY] include_php file with paramters?

From: Date: Thu, 07 Nov 2002 06:21:12 +0000
Subject: Re: [SMARTY] include_php file with paramters?
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6343@lists.php.net to get a copy of this message
Thx, but this Problem works only if the number of Parameters always the same. Under www.ksile.de you can see that the number of parameter is variable. It seems to be a common problem of template engines. I don't like to write my own news script :( bye ksi guido schrieb: > > this does not work, too bad because it should .. and most likely could > with a little adaptive code. > > There are 2 solutions.. > 1 is to do this : > > rather than include_php go: > {php} > $style_id=1; > $action=view; > $newsid=3; > include('news.php'); > {/php} > > this does the exact same thing you are already doing. > > another way would be to make a plugin that does this behind the > scenes. > > I have a site that uses a bunch of little modules on a page and they > need to called with certain attributes.. > so I call it with: > > # note here it may look more difficult because I'm using $smarty and > #default readings, but simply change to modname='news.php' style_id='1' > action='view' > {moddropper modname='topx.php' isoid=$smarty.get.isoid|default:1 table=products > isow=manufacturers_id num=$smarty.get.num|default:15 > look=$smarty.get.look|default:products_date_added way=$smarty.get.way|default:ASC} > > then the plugin: > > /* > * Smarty plugin > * ------------------------------------------------------------- > * Type: function > * Name: function.mod_dropper.php > * Purpose: drops modules in place with attributes... > * Written By: Shaun Guidolin|maddogBytes|DV-DEPOT.com > * ------------------------------------------------------------- > */ > function smarty_function_moddropper($params, &$smarty){ > > #send function as: > # {moddropper modname='modename' var1=$var var2='var', etc...} > > # explode the params function and set them: > $module_wanted = $params[modname]; > foreach($params as $param_key => $param_value) > { > $$param_key = $param_value; #sets $var = value > } > require(base_modulesdir . '/' . $module_wanted); > return; > } > > this will do the trick nicely :) > > Wednesday, November 6, 2002, 10:48:49 AM, you wrote: > > JJ> Try {include_php style_id="1" action="view" newsid="3"} > > JJ> -- Josh > JJ> -----Original Message----- > JJ> From: news [mailto:news@main.gmane.org] On Behalf Of Kai-Uwe Beyer > JJ> Sent: Wednesday, November 06, 2002 10:35 AM > JJ> To: smarty-general@lists.php.net > JJ> Subject: [SMARTY] include_php file with paramters? > > JJ> Hi, > > JJ> i want to rebuild my page with smarty templates. > JJ> I have a big problem with including external scripts, which need > JJ> parameters. > JJ> They get their parameters from the own script. > > JJ> The function > JJ> {include_php file=$news} > > JJ> where > > JJ> $news = news.php?style_id=1&action=view$newsid=3; > > JJ> The smarty enginge gives a error: > > JJ> 'file:/home/web/smarty/docs/news.php?style_id=1&action=view$newsid=3' > JJ> is not readable > > JJ> How i can include external scripts with passing parameters thru this > JJ> scripts? > > JJ> Thx ksi > > JJ> -- > JJ> Smarty General Mailing List (http://smarty.php.net/) > JJ> To unsubscribe, visit: http://www.php.net/unsub.php > > -- > Best regards, > guido mailto:sguido@rogers.com > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

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