3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1421 Views |
-
More than two arguments from template

4 February 2009 at 4:33pm Last edited: 4 February 2009 4:33pm
Hi, I'm trying to call a method of Page_Controller from the template, but if I try to pass in more than two arguments then none of them show up at the other end.
I've got this going on:
Page.php:
class Page_Controller extends ContentController {
function ArgTest($one='default', $two='default', $three='default') {
print_r(func_get_args());
}
}Page.ss:
$ImageTest(new, new, new)
and the output is:
Array ( )
It's not passing the arguments in at all, but if I only pass two in ($ImageTest(new, new)) it works fine:
Array ( [0] => new [1] => new )
Anybody have any ideas what's going on? Is this a limitation of the template engine?
-
Re: More than two arguments from template

4 February 2009 at 5:08pm
I believe that SSViewer (the class that interprets your templates) doesn't handle more than 2 parameters.
Basically, SSViewer parses the template with Regular Expressions. At the current time, these are limited to expressions with 2 parameters or less.
You could probably modify SSViewer.php to handle more parameters if you wanted, but it is unusual to need them. The expressions are kept deliberately simple so it is easy for non-coders (designers, etc) to use. If you start building complicated functions with lots of parameters, you start to loose the compartmentalization.
-
Re: More than two arguments from template

4 February 2009 at 5:27pm
Fair enough I guess, looks like I need to re-think how this bit's going to work.
-
Re: More than two arguments from template

23 November 2010 at 6:16am
I have found an inconsistancy.
If I have a method: getData(var1=1, var2=2){do something etc..}
and I call it in a template as: getData(5,6)
the method is called and var1 is set to 5 and var2 is set to 6.if I call the method without the get, as: Data(5,6)
the method is called and var1 remains default of 1 and var2 remains default of 2.Hamish, maybe you can explain if this is the expected behavior?
I was under the impression that the get and set prefixes could be removed with out any effect? -
Re: More than two arguments from template

23 November 2010 at 9:33pm
DsX: I can confirm your inconsistency, had this same issue on a site I was working on. SSViewer is a part of the code that scares me though so I skipped over trying to find a long term solution.
| 1421 Views | ||
|
Page:
1
|
Go to Top |




