Changing a protected variable on block view
Permalink
in my block controller, I set the following variable:
Question is, what if I want to let the user decide this for themselves? They could enable full width for example and I would then need to change that variable to true. But is there a way to do this?
protected $btIgnorePageThemeGridFrameworkContainer = false;
Question is, what if I want to let the user decide this for themselves? They could enable full width for example and I would then need to change that variable to true. But is there a way to do this?
Sort of how the auto_nav block runs the __construct method itself, my block needs to basically override the __construct method so I can first check a setting in my blocks database, and then set the protected variable to what it should be. After I have retrieved the settings and reset the protected variable, I run the normal construct method the same way it would automatically. Basically, I'm doing some calculations before the controller is even constructed. This is what I came up with inside my block controller:
So, the blocks methods aren't available until its been constructed, so trying to return anything from the controller itself will fail until its actually been constructed. What I'm doing is grabbing the setting from the blocks database using the blocks ID, which also isn't available unless you declare 'protected bID;' at the top of the class. Once I have the settings value, I set the btIgnoreContainer variable accordingly. THEN I run the constructor which takes the newly provided btIgnoreContainer variable and applies itself accordingly.
Basically, I had to go to the very initiation of the entire block class to change the protected variable based on my settings.