[EDIT: I was able to answer my question. Answer posted below.]

EE 5.2.4

I have a class that will query an API using item ID and return data for that item.

I am aware that this structure:


will return the value for this:

class My_class {

  function my_method () {

    // content


However, what I need to do is pass an argument to the class method for each entry within a channel, like this:

{exp:channel:entries channel='products'}
    {exp:my_class:my_method arguments='{product_asin}'}

would return a value from the class method for each product entry:

class My_class {

  function my_method ($asin) {

    // query api based on $asin values passed from the template


It's quite possible I'm missing something in this part in the docs, as they are quite elaborate regarding add-on classes and methods, so I'm hoping someone will just know from experience how to do something like {exp:my_class:my_method arguments='{product_asin}'}.


1 Answer 1


I have found the answer to this.

In the template:

{exp:my_class:my_method asin='{product_asin}'}

In the class:

class My_class {

  function my_method () {

    $asin = ee()->TMPL->fetch_param('asin');
    return 'my asin is: ' . $asin;



On the frontend this renders:

my asin is: [product asin]

So what you have to do is define your parameter in the template asin='{product_asin}' and then fetch it in your method $asin = ee()->TMPL->fetch_param('asin');.

Thanks, me. Oh, you're welcome!


Your Answer

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

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