[SOLVED] CTabView image

Hi all,

first of all: Yii is a great framework. Nice work!!!

I’ve started my first application and I’ve question. I would like to add an image next to Tab Title (CTabView).

I tried something like this:




$Tabs     = array

               (

                  'tab1'=>array('title'=>'<img src="'.Yii::app()->request->baseUrl.'/images/image.png" /> Tab 12 Title','content'=>'test1'),

                  'tab2'=>array('title'=>'Tab 2 Title','content'=>'test2'),

               );



It doesn’t work. So how can I handle this?

Thanks.

Someone an advice?

Thanks!

I haven’t actually looked, but it would surprise me if it didn’t have an html options array to pass to it.

You want to change the class of the tab, and then use css to put images in them.

I could be wrong.

But let’s kick this off with this. :)

Can we see the resulted HTML? (just the tab)

Of course. This is the tab div:




<div class="yiiTab" id="yw0">

<ul class="tabs">

<li><a class="active" href="#tab1"><img src="/webapp/images/image.png"> Tab 1 Title</a></li>

<li><a href="#tab2">Tab 2 Title</a></li>

</ul>

<div id="tab1" class="view">

test1</div><!-- tab1 -->

<div style="display: none;" id="tab2" class="view">

test2</div><!-- tab2 -->

</div>



Thank you for support.

Hi ribber,

No problem. The result HTML is good… could you please describe the problem?

  • I don’t see the image (check your image path)

  • Tabs not working (check the js registered -they should be fine)


Thanks Antonio,

you’re right. Works fine. My problem was that the filename of the image was in capital letters.

For everyone who want also define images in CTabView use the following code:




$Tabs     = array

               (

                  'tab1'=>array('title'=>'<img src="'.Yii::app()->request->baseUrl.'/images/image.png" /> Tab 1 Title','content'=>'test1'),

                  'tab2'=>array('title'=>'Tab 2 Title','content'=>'test2'),

               );



Works also with CJuiTabs:




$this->widget('zii.widgets.jui.CJuiTabs', array(

                'tabs'=>array(

                '<img src="'.Yii::app()->request->baseUrl.'/images/image.png" /> Main info'=>array('ajax'=>array('/site/page','id'=>$model->id)),

                ),



great man…

pleaes update the post to [SOLVED] so people can check for problems/solutions. :)

To do that go to your first post, edit and use full editor.

Congratulations man and thanks for the tip!