Friday 23 August 2013

Side Bar in Yii Framework


In this post I will show you how to put sidebar in Yii framework Web application.

This Sidebar can be displayed on the left or right side of the browser. This slides in on mouse over on the sidebar and slides out automatically when user mouse leaves the sidebar.

Already we have leftsidebar and rightsidebar extensions in Yii framework. But these can be used to display sidebar on either left side or right side of the browser.

But this extension will avoid the use of two different extensions for displaying sidebars on left and right side of browser.

This sidebar can be used to display menu or some other useful things in your application.

 Download and Usage Details:

     You can download this extension at . For Further Comments Please comment below.

      Extract folder to your protected/extensions/ folder.

Example Usage:

You have to specify 'position' to be left or right. If you don't specify it will display in right side. 

in Your view file

array('title' => 'Menu', 'collapsed' => true, 

//here you display a cmenu or gridview or any other 
thing as per your needs.
//or you can simply display contents form variable like below

echo $var;

If you don't specify 'position', Then a right sidebar will be displayed by default. So, if you want a right sidebar then you don't need to specify position in the widget.


Like below a sidebar will b shown either left or right side of your browser based on 'position'.

 Arrow mark as in rightsidebar extension:

You can able to display an arrow mark in your sidebar by just doing some modification the extension. For this do the below steps.

In Sidebar/sidebar.php change the below things

Step 1: Change This,
echo '<div class="title">' ;
        echo  CHtml::encode($this->title);
 echo '</div>';


echo '<div class="title">' ;
        echo CHtml::encode($this->title);
        echo CHtml::ajaxLink('&gt;&gt;', '', false, array('id' => 
        echo '</div>';

Step 2: Change This, 
echo '<div class="title">' ;
  echo  CHtml::encode($this->title);
        echo '</div>';


echo '<div class="title">' ;
        echo CHtml::encode($this->title);
        echo CHtml::ajaxLink('&gt;&gt;', '', false, array('id' => 
        echo '</div>';
and in js folder, 

Step 3: In leftsidebar.js line 64 change Pin and Hide.
Step: 4 And finally in rightsidebar.css line 61 change float to right.

That is it. Now a arrow mark will be displayed in the sidebar. You can click on the arrow mark to display and again click to hide the sidebars.

I think it is useful to someone.


  1. If you Like this and if you feel any Further improvements please Comment below. I know this extension still needs some more things.

  2. great extension works perfectly
    However I would like to change its position and put it a bit higher in my page how can I do it please ?

  3. Nice blog. Thanks for providing such nice information to Yii Developer.

  4. interesting blog. It would be great if you can provide more details about it. Thanks you

    Online Web Development Courses

  5. The information that you have shared was really very useful and looks great to see.Thanks for sharing the information with us.
    Web development company in bangalore
    Web design company bangalore

  6. Nice post.Thank you so much for sharing.Yiioverflow is a web development company.We have well expert team in Angular JS, Ionic, Yii Framework, Node JS, Laravel, PHP, MySQL, and WordPress.If you want a developer visit..

  7. What an amazing job done by the writer.
    mason soiza