For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > June 2004 > Arrays as param to custom functions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Arrays as param to custom functions
Martin Kjeldsen

2004-06-01, 2:45 pm

Hi,

it's it possible to pass functions a assoc array instead of naming all the
variables. That would enable dynamic use of custom functions like
{html_select_date} which takes a lot of parameters and I don't know how to
pass variables if sometimes I want to leave some out. The best solutions
would be to:

{html_select_date $html_select_params}

A simple fix, which I could put in all custom functions, is to just pass a
array
{html_select_date params=html_select_params}

And put this in the custom function

if (isset($params['params']) && is_array($params['params']))
$params = &$params['params'];

of course before the extract or the foreach...

Cheers

Martin
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com