We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Way to get all parameters without knowing the names?

Development and Programming

eeart's avatar
eeart
257 posts
15 years ago
eeart's avatar eeart

Regarding $this->EE->TMPL->fetch_param(‘name’) is there a way to get all parameters if you don’t know their names?

For instance in:

{exp:my_module vara="value" varb="value"}

if you don’t know the names of “vara” and “varb”, is there a way to get the values anyway?

Thank you.

       
Rob Sanchez's avatar
Rob Sanchez
335 posts
15 years ago
Rob Sanchez's avatar Rob Sanchez
foreach ($this->EE->TMPL->tagparams as $key => $value)
{
}
       
eeart's avatar
eeart
257 posts
15 years ago
eeart's avatar eeart

Thank you Rob!

       
aleksblendwerk's avatar
aleksblendwerk
9 posts
15 years ago
aleksblendwerk's avatar aleksblendwerk

I just came across this while experimenting with a new plugin idea as well, so I’d like to ask the actual EE developers: is this ‘safe’ to use then or is this considered a ‘hack’/will likely break soon or anything?

In case it is considered ‘bad’, maybe this should be turned into a feature request for a function that lets developers access get all the tag parameter names and values at once in their plugins. Because this is really useful, in my case the whole add-on handling would be a lot more complicated/a lot more to type for the end users trying to implement it in their own templates.

       
Jack McDade's avatar
Jack McDade
425 posts
15 years ago
Jack McDade's avatar Jack McDade

I wouldn’t see that as bad, but you probably should have an array full of all of your expected params with default values if you do it dynamically like this. It’s better to account for something before hand than to figure out what the heck is happening afterwards 😊

       
aleksblendwerk's avatar
aleksblendwerk
9 posts
15 years ago
aleksblendwerk's avatar aleksblendwerk
I wouldn’t see that as bad, but you probably should have an array full of all of your expected params with default values if you do it dynamically like this. It’s better to account for something before hand than to figure out what the heck is happening afterwards 😊

Sure thing! This is a ‘special case’ though! 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.