Search code examples
phpmodel-view-controllercontrollerconcrete5

Concrete5: Is it possible to access the value set by set() function from another function in the controller?


In my controller's view() function, I have something like this:

function view() {    
  $this->set('myVal', $text);
}

Now is it possible to access $myVal from another custom function inside the controller?

I tried $myVal and $this->myVal but it does not work. Is it only accessible in the add.php, edit.php and view.php and not anywhere else?


Solution

  • You can access it via

    $this->getvar('myVal');
    

    You can also access it via

    $this->get('myVal');
    

    But this is deprecated as that method should now be used for $_GET values