0

If I have a function in a plugin that is normally called with parameters that are retrieved like this:

public function eventtitle() {
    $eventCode = $this->EE->TMPL->fetch_param("event_code");
    $_type     = $this->EE->TMPL->fetch_param("_type");
    // do other stuff
    return $value;
}

How do I call that same function from another function WITHIN the same plugin passing the same parameters?

$coursetitle = $this->eventtitle($eventcode);
2

Conditionals are your friend! Assuming both parameters are required:

public function eventtitle($eventCode=NULL,$_type=NULL)
{

    // is either of our parameters null? 
    // if so, try and get it from the tag!        
    if (is_null($eventCode) || is_null($_type))
    {
        $eventCode = $this->EE->TMPL->fetch_param("event_code");
        $_type     = $this->EE->TMPL->fetch_param("_type");
    }

    // do other stuff
    return $value;
}

And then just call it with params:

$coursetitle = $this->eventtitle("Event Code 1", "Type Var 1");
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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