Smarty - Nested/Chained function calls when using Objects
When using Smarty, I've been trying to embed something like the following to chain method calls together :
{$theObject->getUser()->getName()}
That, at least with Smarty 2.4.14, doesn't work.
Thankfully, #smarty on freenode, provided the following fix which I'll include here, just incase the link breaks :
Index: Smarty_Compiler.class.php
===================================================================
RCS file: /repository/smarty/libs/Smarty_Compiler.class.php,v
retrieving revision 1.382
diff -u -r1.382 Smarty_Compiler.class.php
--- Smarty_Compiler.class.php 28 May 2006 17:35:05 -0000 1.382
+++ Smarty_Compiler.class.php 11 Jul 2006 14:57:13 -0000
@@ -161,7 +161,7 @@
$this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
. '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)';
$this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
- $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)';
+ $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . '' . '(?:' . $this->_obj_ext_regexp . $this->_obj_params_regexp . ')*' . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)';
// matches valid modifier syntax:
// |foo
So that now works properly, and I don't have to do something nasty like :
Recent comments
2 days 20 min ago
2 days 21 hours ago
4 days 19 hours ago
5 days 17 hours ago
5 days 17 hours ago
1 week 2 hours ago
1 week 1 day ago
1 week 1 day ago
1 week 1 day ago
1 week 1 day ago