Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

{insert name=$my_dynamic_name} ???

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
q_no
Smarty Rookie


Joined: 22 Nov 2005
Posts: 13
Location: germany

PostPosted: Tue Nov 22, 2005 3:51 pm    Post subject: {insert name=$my_dynamic_name} ??? Reply with quote

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
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Nov 22, 2005 5:03 pm    Post subject: Reply with quote

Maybe try: `$element.obj_type`
Back to top
View user's profile Send private message
q_no
Smarty Rookie


Joined: 22 Nov 2005
Posts: 13
Location: germany

PostPosted: Tue Nov 22, 2005 10:13 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Milkman
Smarty Regular


Joined: 21 Nov 2005
Posts: 57
Location: Loughborough, UK

PostPosted: Wed Nov 23, 2005 1:56 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
q_no
Smarty Rookie


Joined: 22 Nov 2005
Posts: 13
Location: germany

PostPosted: Wed Nov 23, 2005 8:26 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Nov 23, 2005 10:14 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP