Sunday, November 24, 2013

How to add Bootstrap in Yii Framework



As bootstrap the most famous CSS framework in web designing and in the parallel side i-e web development the king of frameworks is Yii framework as it is fast and most secure one amongst others, anyone with the knowledge of both would surly like to combine the power of both in many projects but there are others which want to experiment or some are just the beginners in both, well you have came to right place. Enough talk lets roll it.

Requirements:

i will be assuming that you have installed and configured the Yii framework, if not then let me know i will write a post on how to install/configure Yii and get started with it.

Step 1:

 Extract all the files from the Bootstrap compressed file into your applications protected/extensions/bootstrap directory.

Step 2:

Open main.php from protected/config directory in any text editor like notepad++. in the very beginning of the file you will find this:

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
Type this under these lines:
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
now scroll down and you will find
        // application components
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),
.........
and in the components array add this:
'bootstrap'=>array(
			'class'=>'bootstrap.components.Bootstrap',
		   ),

like this:
        // application components
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),
		'bootstrap'=>array(
			'class'=>'bootstrap.components.Bootstrap',
		   ),

Step 3:

Now the final Step, open the main.php located at protected/view/layouts and add the following line right before the closing head tag (</head>).

<?php Yii::app()->bootstrap->register(); ?>

Now you are good to go...

Example:

To use the Bootstrap fixed navbar in your project, open the main.php located at protected/view/layouts and find the main menu div which has id of "mainmenu" and replace its inner code with the following code. Voila! you have the Bootstrap fixed navigation menu now installed in your project.
        <?php $this->widget('bootstrap.widgets.TbNavbar',array(
            'type'=>'inverse',
            'items'=>array(
                array(
                    'class'=>'bootstrap.widgets.TbMenu',
                    'items'=>array(
                        array('label'=>'Home', 'url'=>array('/site/index')),
                        array('label'=>'Test', 'url'=>array('test/test')),
                        array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
                        array('label'=>'Contact', 'url'=>array('/site/contact')),
                    ),
                ),
                array(
                    'class'=>'bootstrap.widgets.TbMenu',
                    'htmlOptions'=>array('class'=>'pull-right'),    //  Bottons appears at the right side of the Navigation Bar.
                    'items'=>array(
                        array('label'=>'login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
                        array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
                    ),
                ),
            ),
            )); ?>

You can customize most of the elements in your Yii project with this extension. To get more into the Yii Bootstrap visit Yii-Bootstrap site to get the codes of more components and how to use them. You can use the Yii-Bootstrap discussion forum at Yii to get to know more and discuss any issues you might have with Yii-Bootstrap.

If you liked this post or this was helpful to you subscribe my blog to get more interesting topics.

Friday, September 13, 2013

GTA V XBOX 360 Leaked on torrent site ahead of official release


I can't believe it the most anticipated game of 2013 GTA V is poping up on torrent sites ahead of its official release and by the comments and images posted by the downloaders (leachers) has confirmed that the copy is legit. the official release date for the GTA V is 17 september. Earlier today on the internet i stumbled upon a post in which one guy was claiming that a store at his town was willing to sell GTA V ahead of its release for about 90 Dollars.

the sites i have found the torrents on had shared some of the in game screen shots here check them out:

http://i.imgur.com/iRX73XZ.jpg
http://i.imgur.com/vYiu6Fl.jpg

Gameplay Videos:





4 hours long gameplay Video :



GTA V - German 09/15 by GameCreds

About Me

My photo
I play a lot of computer games, design stuff and enjoy the life with my cutest baby girl.