Yii Framework Forum: Sub widgets and Master widget - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Sub widgets and Master widget Rate Topic: -----

#1 User is offline   Rodi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 07-January 10

Posted 06 February 2010 - 11:54 PM

I have a series of widgets (sub widgets) that share common HTML btw them, I was wondering how I could create a "master" widget to output the common HTML.

<div class="module subWidgetNameModule">
  <h3>Sub widget Title</h3>
   <div class="moduleContent">
       ...sub widget content...
    </div>
</div>

0

#2 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 07 February 2010 - 03:01 AM

It seems that you need to create a parent widget, and rewrite it's run() method to output something like:

<div class="module <?=$this->id?>Module">
  <h3><?=$this->getTitle()?></h3>
   <div class="moduleContent">
       <?=$this->getContent()?> 
   </div>
</div>


All child widgets should provide getTitle() and getContent() methods, so you can declare them as "abstract" in your parent (master) widget.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users