Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Passing variables

edited February 2007 in Vanilla 1.0 Help
I'm sure this problem is a product of my lack of general OOP knowledge and the manner in which I'm doing things but if someone could explain to me how I pass a variable from a control to a body onLoad function, I'd be eternally grateful.

Loose idea is this:

class className extends PostBackControl { var $variable; function className(&$Context) { ... } function Render() { //set variable to say "10" value here with what syntax? } } $Context->BodyAttributes .= " onload=passVariable(".$Context->className->$variable.") ";

Obviously i'm getting nothing but I quite clearly don't understand referencing and setting variables from different stages of a control. Is it that its too late to pass something to the body attributes once at the Render stage? I was thinking everything was parsed before rendering? Confused...

thanks for any help.


  • Options
    I'm not sure if $Context contains a refrence to all present class names... but I do know it contains an array that you can pass information in and out of:

    class className extends PostBackControl { var $variable; vat $Context; // be sure to pass $Context in the constructor like the core Vanilla classes... function Render() { $this->Context->PassThruVars['variable'] = 10; } } $Context->BodyAttributes .= 'onload="passVariable(\''. $Context->PassThurVars['variable'] .'\');" ';
This discussion has been closed.