Re: custom functions

From: Date: Wed, 20 Feb 2002 22:28:10 +0000
Subject: Re: custom functions
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2802@lists.php.net to get a copy of this message
and what is line 868 in addons? chiefmonkey wrote: > > Had a look at the page in opera and got the following result > > http://www.experimentalmonkey.co.uk/opera_screenshot.gif > > George > > At 15:43 20/02/2002 -0600, Monte Ohrt wrote: > >It looks like it is trying to do the right thing. put some debugging > >echos in there to see if is doing what you expect, or if the function is > >even being executed. > > > >chiefmonkey wrote: > > > > > > Here's the function > > > > > > function smarty_func_getimage($path) { > > > > > > $imagelist=array(); > > > > > > $handle=opendir($path); > > > > > > while(false !==($file = readdir($handle))) { > > > > > > if ($file !="." && $file !="..") { > > > > > > $ext=substr($file, -4); > > > > > > // if you wish to add .png to the list of files > > > // uncomment the line below and delete the original line > > > //if ($ext == ".jpg" || $ext==".gif" || $ext==".png") { > > > > > > if ($ext == ".jpg" || $ext==".gif") { > > > > > > array_push($imagelist, "$file"); > > > } > > > > > > } > > > > > > } > > > > > > srand((double) microtime()* 1000000); > > > > > > $names=$imagelist; > > > > > > $rand_keys = array_rand($names,2); > > > > > > $adimage=$names[$rand_keys[0]]; > > > > > > $alt=substr($adimage,0,-4); > > > > > > $adimage="$path/".$adimage; > > > > > > $size=GetimageSize($adimage); > > > > > > $display="<img src=\"$adimage\" $size[3] alt=\"$alt\" > > > />"; > > > > > > echo"$display"; > > > > > > closedir($handle); > > > > > > } > > > > > > Thanks for the help so far > > > > > > George > > > > > > At 15:31 20/02/2002 -0600, Monte Ohrt wrote: > > > >OK, and then what does it do? It shouldn't try to send the image binary > > > >to the template, if that is what it's doing. It should return a path to > > > >the image, so the browser will go back after the template loads to get > > > >the image. > > > > > > > >so something like this in your template: > > > > > > > ><img src="{getimagepath}"> > > > > > > > >where getimagepath would display the path to the image relative to the > > > >document root. > > > > > > > > > > > >chiefmonkey wrote: > > > > > > > > > > It grabs an image at random from a specified directory > > > > > > > > > > George > > > > > > > > > > At 15:23 20/02/2002 -0600, Monte Ohrt wrote: > > > > > >What does getimage do exactly? dump image data to the browser? > > > > > > > > > > > >chiefmonkey wrote: > > > > > > > > > > > > > > I now have it working, in as much as it doesn't display > > > > > > > an error > > > > > > > message, however the browser window won't load and it keeps > > > > crashing now. > > > > > > > > > > > > > > George > > > > > > > > > > > > > > At 15:11 20/02/2002 -0600, Monte Ohrt wrote: > > > > > > > >wrong syntax for one: > > > > > > > > > > > > > > > >{getimage name="val" name2="val2"} > > > > > > > > > > > > > > > >chiefmonkey wrote: > > > > > > > > > > > > > > > > > > I am trying to create a custom function so I added it > > > > > > > > > to > > > > > > > > > Smarty.addons and named it > > > > > > > > > smarty_func_getimage > > > > > > > > > > > > > > > > > > I then added it to the custom functions array in > > > > > > > > > Smarty.class > > > > > > > > > 'getimage' => > > > > > > > > > 'smarty_func_getimage' > > > > > > > > > > > > > > > > > > and I am trying to call it from my template > > > > > > > > > > > > > > > > > > {getimage:"path/to/images"} > > > > > > > > > > > > > > > > > > but I keep getting this error > > > > > > > > > > > > > > > > > > syntax error: unknown tag - 'getimage > > > > > > > > > > > > > > > > > > TIA > > > > > > > > > > > > > > > > > > George > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --- > > > > > > > > > You are currently subscribed to smarty as: > > > > > > > > > monte@ispi.net > > > > > > > > > To unsubscribe send a blank email to > > > > > > $subst('Email.Unsub') > > > > > > > > > Visit Smarty's homepage at > > > > http://www.phpinsider.com/php/code/Smarty/ > > > > > > > > > > > > > > > >-- > > > > > > > >Monte Ohrt <monte@ispi.net> > > > > > > > >http://www.ispi.net/ > > > > > > > > > > > > > > --- > > > > > > > You are currently subscribed to smarty as: monte@ispi.net > > > > > > > To unsubscribe send a blank email to > > > > $subst('Email.Unsub') > > > > > > > Visit Smarty's homepage at > > http://www.phpinsider.com/php/code/Smarty/ > > > > > > > > > > > >-- > > > > > >Monte Ohrt <monte@ispi.net> > > > > > >http://www.ispi.net/ > > > > > > > > > > > >--- > > > > > >You are currently subscribed to smarty as: > > > > chiefmonkey@wisemonkeydesign.co.uk > > > > > >To unsubscribe send a blank email to > > $subst('Email.Unsub') > > > > > >Visit Smarty's homepage at > > > > > >xŠ´0¥èï÷xáÍÄhttp://www.phpinsider.com/php/code/Smarty/ > > > > > > > >-- > > > >Monte Ohrt <monte@ispi.net> > > > >http://www.ispi.net/ > > > > > > > >--- > > > >You are currently subscribed to smarty as: > > chiefmonkey@wisemonkeydesign.co.uk > > > >To unsubscribe send a blank email to $subst('Email.Unsub') > > > >Visit Smarty's homepage at > > > >http://www.phpinsider.com/php/code/Smarty/ > > > >-- > >Monte Ohrt <monte@ispi.net> > >http://www.ispi.net/ > > > >--- > >You are currently subscribed to smarty as: chiefmonkey@wisemonkeydesign.co.uk > >To unsubscribe send a blank email to $subst('Email.Unsub') > >Visit Smarty's homepage at > >http://www.phpinsider.com/php/code/Smarty/ -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

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