Error when I have multiple instances of a block on a single page
Permalink
I'm developing a weather block and it is working perfectly well. Except if I have more than one instance of the block on a single page. Then I get "Whoops \ Exception \ ErrorException (E_ERROR)".
The exception always rises at the last function of my "view.php". I've tried to change the order of the functions and the party always stops at the last function regardless.
Please point me in the right direction – it's probably some total rookie error since this is my first attempt to develop a block.
The block is here:https://github.com/o3jvind/cool_weather...
The exception always rises at the last function of my "view.php". I've tried to change the order of the functions and the party always stops at the last function regardless.
Please point me in the right direction – it's probably some total rookie error since this is my first attempt to develop a block.
The block is here:https://github.com/o3jvind/cool_weather...
BIG THANX
Moved the functions to the controller.
I have a working block now :-)
https://github.com/o3jvind/cool_weather...
Moved the functions to the controller.
I have a working block now :-)
https://github.com/o3jvind/cool_weather...
Solutions:
General: Never declare functions outside of a class
Then
a) Move these functions into the block controller, call them from the view as
$controller->methodName()
or
b) Move the functions into a separate class, instantiate that in the view and call them on the instance.