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

Variable Parameters

 
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 -> Feature Requests
View previous topic :: View next topic  
Author Message
cbschuld
Smarty n00b


Joined: 22 Aug 2005
Posts: 1
Location: Gilbert, Arizona

PostPosted: Mon Aug 22, 2005 8:50 am    Post subject: Variable Parameters Reply with quote

Hello All:

I have a request to have variable-based parameters for smarty plugins -- OR -- I do not fully understand how to use them if this is already supported.

Here is what I would like to do:

I have a plugin function called smarty_function_request that requires variable parameter values. Here are a few examples of what I am attempting to do:

Code:

{request someparameter-$pageid1=7 someparameter-$pageid2=7}

{request someparameter-$id[0]=7 someparameter-$id[1]=7}

{request someparameter-$object->getId()=7 someparameter-$anotherObject->getId()=7}




These smarty statements would then be essentially aliases of the following (assuming the following values: $pageid1 = 1, $pageid2 = 2, $id[0] = 'cat', $id[1] = 'dog', $object->getId() returns 23, $anotherObject->getId() returns 24):

Code:

{request someparameter-1=7 someparameter-2=7}

{request someparameter-cat=7 someparameter-dog=7}

{request someparameter-23=7 someparameter-24=7}






What I would see in my plugin then would be "processed" parameters.

If there is already support for this then egg on my face, but please let me know!

Thanks for all the great work!

--Chris
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Aug 22, 2005 4:36 pm    Post subject: Reply with quote

You can't, nor should you have to. Parameter names are a known item. Maybe you should just pass an associative array of values:

Code:
{request params=$params}


where $params would be:

Code:
$params = array(
  'pageid1' => '1',
  'pageid2' => '2',
  'id[0]' => 'cat'
);
Back to top
View user's profile Send private message 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 -> Feature Requests 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