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.

Render() and other fucntions

Render() seems to behave differently
class DisplayNugget extends Control { var $DisplayString; function DisplayNugget(&$Context) { $this->Name = 'DisplayNugget'; $this->DisplayString = $DisplayString; } function Render() { echo $this->DisplayString; } function DisplayPanel () { return $this->DisplayString; } }

The render function cannot return the variable. it has to echo it.
The other functions need to return and not echo. if they echo the result is not what u want. For eg If u use
$Panel->AddString($DisplayNugget->DisplayPanel());
this will not put the result in the Panel but rather on the top of the page

$Page->AddRenderControl($DisplayNugget, $Configuration[CONTROL_POSITION_PANEL])
this will not work if Render doesn't echo, and uses return instead.

Is it just me?

Comments

  • That's the normal behavior. With the panel way, you give a string to the Panel. And the Panel, when its render method is fired, render it inside the list . With the Control way, you give an instance of a Render Control to the Page control. When everything has been processed, the Page control execute the render method of the Render Controls that have been added to it, that's all. It doesn't do anything with what the render methods return.
  • So i should take out the Panel function out of the control class.
    It works as it is now. but i thuink that is bad programming to be doing it the way above.
  • I don't know about that. document.write in JavaScript is bad ;-)
This discussion has been closed.