i need a conditionally display content between beginWidget and endWidget. In widget`s class i have attribute $visible to store information about visibility. How can i get this value from view file? I have to use static function but then i can not use $this->visible.
i need a conditionally display content between beginWidget and endWidget. In widget`s class i have attribute $visible to store information about visibility. How can i get this value from view file? I have to use static function but then i can not use $this->visible.
So, i would do a conditionally display content between beginWidget and endWidget in my widget, which has attribute visible. On the basis of this variable i show header and footer widget.
<?php $this->beginWidget('application.modules.portlet.components.Portlet',array(
'id'=>'userInfo1',
'title'=>'User info',
'visible'=>true,
)); ?>
...body content that may be captured by the widget...
<?php $this->endWidget(); ?>
<?php $this->beginWidget('application.modules.portlet.components.Portlet',array(
'id'=>'userInfo2',
'title'=>'User info',
'visible'=>false,
)); ?>
...body content that may be captured by the widget...
<?php $this->endWidget(); ?>
Problem is, when widget is invisible because the text “…body content that may be captured by the widget…” will still be displayed
So i did so:
<?php $this->beginWidget('application.modules.portlet.components.Portlet',array(
'id'=>'userInfo2',
'title'=>'User info',
'visible'=>false,
)); ?>
<?php if(Portlet::$visibility): ?>
...body content that may be captured by the widget...
<?php endif; ?>
<?php $this->endWidget(); ?>
where variable $visibility is static variable.
Maybe this solution is not good but works. I solved my problem in this way, because i don`t know how to do capture body by the widget.
In post http://www.yiiframew…72.html#msg5172 you write that i can use ob buffer to capture the body content or alternatively, i can extend COutputProcessor.
Unfortunately i could not do so.
Maybe you would find some time to write an example how to do capture body by the widget.