Showing posts with label boostrap. Show all posts
Showing posts with label boostrap. Show all posts

Wednesday, April 17, 2013

Yii Framework - Twiiter Bootstrap TbMenu in Navbar options

To get the image to work just embed an image in the brand name like so:


'brand'=>'<img src="path_to_img.jpg"/>"

Add extra parameters to TbMenu

'itemOptions' not 'htmlOptions' when an item has htmlOptions. So to add an id use:

array('label'=>'First Link', 'url'=>"#", 'itemOptions'=>array('id' => 'xyz'))
 

Define $this->activeMenu in your main Controller and 

set value to $this->activeMenu from anywhere.

 
<?php 
if($this->activeMenu == null) {
    $this->activeMenu = "null";
}
$this->widget('bootstrap.widgets.TbNavbar',array(
    'items'=>array(
        array(
            'class'=>'bootstrap.widgets.TbMenu',
            'items'=>array(
                array(
                    'label'=>'Home', 
                    'url'=>array('/site/index'), 
                    'visible'=>Yii::app()->user->isGuest
                ),
                array(
                    'label'=>'About', 
                    'url'=>array('/site/page', 'view'=>'about'), 
                    'visible'=>Yii::app()->user->isGuest
                ),
                array(
                    'label' => 'Contact group', 
                    'url' => array('/group/index'),
                    'itemOptions' => array(
                        "class" => "group_nav"
                    ),
                    "active" => $this->activeMenu == "group_nav"
                ),
                array(
                    'label' => 'Contact list', 
                    'url' => array('/contact/index'),
                    'itemOptions' => array(
                        "class" => "contact_nav"
                    ),
                    "active" => $this->activeMenu == "contact_nav"
                ),
                array(
                    'label'=>'Logout ('.Yii::app()->user->name.')', 
                    'url'=>array('/site/logout'), 
                    'visible'=> !Yii::app()->user->isGuest
                )
            )
        )
    )
)); 
?> 

Monday, April 8, 2013

yii bootstrap install and buttons types



Setup

Download the latest release from Yii extensions by following the link below:
Download Yii-Bootstrap
Unzip the extension under protected/extensions/bootstrap and modify your application configuration accordingly:
If you wish to use the provided Bootstrap theme copy the theme directory to your themes directory.
// Define a path alias for the Bootstrap extension as it's used internally.
// In this example we assume that you unzipped the extension under protected/extensions. 
// Add the following line to /protected/config/main.php 
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
 
return array(
    'theme'=>'bootstrap', // requires you to copy the theme under your themes directory
    'modules'=>array(
        'gii'=>array(
            'generatorPaths'=>array(
                'bootstrap.gii',
            ),
        ),
    ),
    'components'=>array(
        'bootstrap'=>array(
            'class'=>'bootstrap.components.Bootstrap',
        ),
    ),
);
You're done! Now you can start using Bootstrap in your application. For examples on how to use the widgets please visit the docs.