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);

1 Answer 1

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");

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.