How can a block get a variable that is set in the page?

So, in my page controller I have a variable set, which will be used to inform the block on that page how to act under certain circumstances.... for example if the page is application/single_pages/shows/episode.php::view($showname), and the url is /episode/startrek, then startrek is the an argument passed to the page controller, and I want that argument to be sent to the custom block controller called shows (for example)... and this block uses that arguemtn to filter it's query againt a database of shows... that sort of thing.

I can not see how to get the $showname variable to be seen by the block. However, if I dump $this from the block controller, I can clearly see $showname in there.

What is teh 'secret' invcation of functions I need to get that?


View Replies:
kieranrushby replied on at Permalink Reply
A bit of a shot in the dark but the block_controller extends controller which has a method called getControllerParameters().

Will $this->getControllerParameters() give you the desired result?
ntisithoj replied on at Permalink Reply
with $this->getControllerParameters() I get

Call to undefined method Application\Block\FilterSelect\Controller::getControllerParameters()
theneptune replied on at Permalink Reply
Get-parameters are available via the controllers. In the view of a page or block use:

ntisithoj replied on at Permalink Reply
with $this->controller->get("showid"))

Call to a member function get() on a non-object

which is weird because how can the $controller be a non-object?

I have abandoned the problem and got around it simply passing parameters on the query string, "?sid=111", for example... and then get it from the $_REQUEST. This works fine, it's just a tiny bit 'uglier'

Thanks for the feedback