|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
q_no Smarty Rookie
Joined: 22 Nov 2005 Posts: 13 Location: germany
|
Posted: Tue Nov 22, 2005 3:51 pm Post subject: {insert name=$my_dynamic_name} ??? |
|
|
Hi!
I want to include PHP-functions dynamicly in forexample this way:
{insert name=$element.obj_type script="/var/www/webXXX/html/_lib/`$element[obj_type]`.php"}
but all I get is this error message:
Parse error: parse error, unexpected T_STRING, expecting ')' in /var/www/webXXX/smarty/templates_c/%%10^104^104DB7B9%%seite.tpl.php on line 4
isn't it possible to assign the name for the {insert} function from a variable? (security reasons?) _________________ $_REQUEST - WHAT YOU $_POST IS WHAT YOU $_GET |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Nov 22, 2005 5:03 pm Post subject: |
|
|
Maybe try: `$element.obj_type` |
|
Back to top |
|
q_no Smarty Rookie
Joined: 22 Nov 2005 Posts: 13 Location: germany
|
Posted: Tue Nov 22, 2005 10:13 pm Post subject: |
|
|
that makes no difference, I've read the manual about "how to insert variables in quotes" and everything else I found, but it does not work.
So, maybe one of the developers knows if this is a bug or ("security") feature? _________________ $_REQUEST - WHAT YOU $_POST IS WHAT YOU $_GET |
|
Back to top |
|
Milkman Smarty Regular
Joined: 21 Nov 2005 Posts: 57 Location: Loughborough, UK
|
Posted: Wed Nov 23, 2005 1:56 am Post subject: |
|
|
Could you try to use {assign} and then output the value to make sure that it's working happily. It'll also give you the chance to see what the value actually is! E.g. Code: | {assign var=filename value="/var/www/webXXX/html/_lib/`$element[obj_type]`.php"}
{$filename} |
Otherwise you could try to use the cat modifier, it's not the neatest method, but if it works... Code: | {insert name=$element.obj_type script="/var/www/webXXX/html/_lib/"|cat:$element[obj_type]|cat:".php"} |
|
|
Back to top |
|
q_no Smarty Rookie
Joined: 22 Nov 2005 Posts: 13 Location: germany
|
Posted: Wed Nov 23, 2005 8:26 am Post subject: |
|
|
The filename is no problem. I've tried this:
{insert name="TESTNAME" script="/var/www/webXXX/html/_lib/`$element[obj_type]`.php"}
and it worked fine, but it seems like, that it's not possible to set the name-parameter by a variable. _________________ $_REQUEST - WHAT YOU $_POST IS WHAT YOU $_GET |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Nov 23, 2005 10:14 am Post subject: |
|
|
q_no wrote: | but it seems like, that it's not possible to set the name-parameter by a variable. |
correct. that's a limitation of {insert}.
you can work around this when by dispatching dynamically in php land (inside your insert-function). |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|