Help with Setting Page Type Controller Variables

Permalink 1 user found helpful
I'm building a package that has a page_type with a coupled controller. I've successfully tested that the view is being called in the controller by adding

public function view() {
echo 'are you viewing?';   
   }


Peachy. Now, however, I am having trouble setting variables that should be available in view. So I have this:
public function view() {
$this->set('message', 'Working?');
}


And in my page type I have:

echo $message;


Which from documentation, should work right? $message is null in the view. I've even tried setting variables in the on_start function to no avail either.

In the on_start function of the controller, I am adding js and css, however, and that is getting put into the view just fine. Am I missing something really obvious?

Thanks,

-Jeramy

jeramy
 
Mnkras replied on at Permalink Reply
Mnkras
i think that should work, i vaguely remember something about arrays, not sure, possibly doing it on_start? can't remember, im too tired :P
jeramy replied on at Permalink Reply
jeramy
I've tried on_start and even tried to grab $_REQUEST['message'] in the view.

I can call functions from the controller, I just can't get any variables from it.

I should also say that I've moved this from a page type to a single page, with no luck.
jeramy replied on at Permalink Reply
jeramy
Maybe this is the key:

I inspected a couple other controllers and found this
/* automagically run by the controller once we're done with the current method */
   /* method is passed to this method, the method that we were just finished running */
   public function on_before_render() {
      if ($this->error->has()) {
         $this->set('error', $this->error);
      }
   }


Added it to my controller and pow! we're in good shape.