I want to remove some items from a page when certain conditions apply. I got a solution but I'm wondering if there isn't any better way to do this.
Now the code that I have is for each block that I want to remove:
protected function _toHtml() {
if ($condition) {
return '';
}
return parent::_toHtml();
}
Now I was wondering if ther is a way to remove a container from the layout file instead of doing this for every block inside a single container. I tried something like this but it does not work:
protected function _toHtml() {
if ($condition) {
$this->getLayout()->removeOutputElement('container.name.in.layout');
return '';
}
return parent::_toHtml();
}
Anyone know's how to remove containers form the layout page within a block class, thanks.