3

Apologies if this is very obvious for experienced addon devs, but I'm experimenting with writing more bespoke plugins rather than gluing together other people's...

I know the official way to fetch parameters is one-by-one by name with $this->EE->TMPL->fetch_param('key'), but I'm currently writing a plugin in which I'd like to iterate over my tag's parameters without having to define in advance what those parameters are in my plugin class.

I see that I can access the tag parameters array directly via $this->EE->TMPL->tagparams, but is it safe to do so?

As far as I can see from reading the Template parser source, fetch_param() just does a bit of tidying up to ensure tag params are uniformly formatted and returns false if a requested param is not set, neither of which are a concern in my use case. However, I want to be sure I'm not introducing unnecessary fragility (or indeed a vulnerability) into my plugin inadvertently.

2 Answers 2

4

Take a look at the fetch_param() method in the Template library. There you can see all it does is return the value of the given key in the tagparams array, offering a fallback default.

So, it should be completely safe, unless EllisLab decides to make it a private property, which I doubt they'll do.

1
  • Thanks Low, thought that was the case but wanted to be sure I wasn't doing something stupid!
    – Tom Davies
    Feb 11, 2013 at 14:50
2

Plenty of add-ons rely on that public tagparams property (ours included). So you would certainly not be the first to rely on it (e.g. my answer here).

That doesn't mean EllisLab won't change/break it in future, but rest assured your add-on won't be the only one that breaks :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.