Re: custom function failure

From: Date: Tue, 27 Mar 2001 19:57:04 +0000
Subject: Re: custom function failure
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-459@lists.php.net to get a copy of this message
Aside from your custom function issue, what is this function accomplishing? Maybe I'm missing something, but you should be able loop through your menu data in a section and display file/web/ftp data using {fetch ...}. You also have HTML formatting in your function... unless the function is specifially for HTML formatting (i.e. {html_options ...}), I would recommend keeping the formatting in a template, especially <font> tags, or anything thing strictly for formatting output. That is what templates are for, yes? example (untested): {section name=mystuff loop=$menu} {if not $mystuff/is_query} {* is_query is boolean passed to template *} <a href="?$menu[$i]"> {/if} <font style="COLOR: #ffffff" face="Verdana,Arial,Helvetica" size="2"> <span class="LeftNavChosen" buttonType="LeftNavChosen">&#149;&nbsp; {$mystuff/menu|str_replace:"_":""|ucwords} </span> </font> {if not $mystuff/is_query} </a> {/if} <br> <img src="assets/line.gif" width="164" height="2"><br> {/section} taliku@balcab.ch wrote: > > Hello everyone, > i have a little problem with creating a custom function: > > I've made a function wich should create a menu: > > /*======================================================================*\ > Function: smarty_func_makemenu > Purpose: fetch file, web or ftp data and display results > \*======================================================================*/ > function smarty_func_makemenu($menu, $qstring) { > // create array > // Count arrray > $anz = count($menu); > // create menu > for($i=0; $i<$anz; $i++){ > if(eregi($menu[$i],$qstring)){ > echo "<font style=\"COLOR: #ffffff\" > face=\"Verdana,Arial,Helvetica\" size=\"2\"><span > class=\"LeftNavChosen\" > > buttonType=\"LeftNavChosen\">&#149;&nbsp;".ucwords(str_replace("_"," > ",$menu[$i]))."</span></font><br><img > src=\"assets/line.gif\" width=\"164\" > height=\"2\"><br>\n"; > } else { > echo "<a href=\"?$menu[$i]\"><font style=\"COLOR: > #ffffff\" > face=\"Verdana,Arial,Helvetica\" size=\"2\"><span > class=\"LeftNavOff\" > buttonType=\"LeftNav\">".ucwords(str_replace("_"," > ",$menu[$i]))."</span></font></a><br><img > src=\"assets/line.gif\" > width=\"164\" height=\"2\"><br>\n"; > } > } > } > > The i registred it in Smarty.class.php: > > 'makemenu' => 'smarty_func_makemenu' > > Now i call the function in my template like this: > > {makemenu > > menu="home_/_news","projects","downloads","gaming","my_n-theme","site_info" > qstring=$qstring} > > But it dont work: i get the half-menu and following errors: > > Warning: Missing argument 2 for smarty_func_makemenu() in > e:\htdocs\n-theme.com\site\smarty.add.php on line 349 > Warning: REG_EMPTY:½empty (sub)expression in > e:\htdocs\n-theme.com\site\smarty.add.php on line 361 > Warning: REG_EMPTY:½empty (sub)expression in > e:\htdocs\n-theme.com\site\smarty.add.php on line 361 > > Does anyone know the problem? what can i do? > > Thanks in advance > taliku > > Sorry for the bad english :) > > --- > 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/

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