Yii-extension Bootstrap: navbar 'pull-right' class - yii

I am trying to align one of the navbars texts to the right but nothing I try is working.
My code is:
<?php $this->widget('bootstrap.widgets.BootNavbar', array(
'fixed'=>true,
'brand'=>'',
'brandUrl'=>'#',
'collapse'=>true, // requires bootstrap-responsive.css
'items'=>array(
array(
'class'=>'bootstrap.widgets.BootMenu',
'items'=>array(
array('label'=>'Weblog', 'url'=>'#'),
array('label'=>'Local RiverMap', 'url'=>'#', 'items'=>array(
array('label'=>'Radar', 'url'=>'#'),
array('label'=>'Cosmo7', 'url'=>'#'),
array('label'=>'Neige', 'url'=>'#'),
array('label'=>'Fonte Neige', 'url'=>'#'))),
array('label'=>'Global RiverMap', 'url'=>'#', 'items'=>array(
array('label'=>'Precipitations 24h', 'url'=>'#'),
array('label'=>'Precipitations 72h', 'url'=>'#'),
array('label'=>'Precipitations 240h', 'url'=>'#'))),
array('label'=>'Espace Expert', 'url'=>'#'),
array('label'=>'Tableau Du Bord', 'url'=>'#', 'items'=>array(
array('label'=>'Tableau du Bord', 'url'=>'#'),
array('label'=>'Niveau de Lacs', 'url'=>'#'),
array('label'=>'Prevision LEPS', 'url'=>'#'),
array('label'=>'Performance', 'url'=>'#'),
array('label'=>'Exported Files', 'url'=>'#'))),
array('label'=>'Admins', 'url'=>'#', 'items'=>array(
array('label'=>'Edit Menu', 'url'=>'#'),
array('label'=>'Edit Google Objects', 'url'=>'#'),
array('label'=>'Insert Internal Message', 'url'=>'#'),
array('label'=>'Message log', 'url'=>'#'),
array('label'=>'Insert Clients Message', 'url'=>'#'))),
array('label'=>'logout', 'url'=>'#', 'htmlOptions'=>array('class'=>'pull-right')),
),
),
))); ?>
As you can see I want last item 'logout' to be at the right side of the navbar but I really don't know how to do it and I can't find any info in the web. The only thing I have seen is using the
'htmlOptions'=>array('class'=>'pull-right') but it doenst seem to work.
When I execute the code with fire bug I can see as that element has 'class'=''.
I would also like to know how I can introduce an image in any navbar item!
Thank you!

The only real difference I see between your BootNavBar widget and mine is that I have 'fixed' set to false and I have 2 BootMenus, the second BootMenu calls the class=>'pull-right'.
$this->widget('bootstrap.widgets.BootNavbar', array(
'fixed'=>false,
'brand'=>CHtml::encode(Yii::app()->name),
'brandUrl'=>'/',
'collapse'=>true,
'items'=>array(
array(
'class'=>'bootstrap.widgets.BootMenu',
'items'=>array(
array('label'=>Yii::t('layouts','Home'), 'url'=>array('/site/index')),
array('label'=>Yii::t('layouts','About'), 'url'=>array('/site/page', 'view'=>'about')),
array('label'=>Yii::t('layouts','Contact'), 'url'=>array('/site/contact')),
),
),
array(
'class'=>'bootstrap.widgets.BootMenu',
'htmlOptions'=>array('class'=>'pull-right'),
'items'=>array(
array('label'=>Yii::t('layouts','Login'), 'url'=>array('/login'), 'visible'=>Yii::app()->user->isGuest),
),
),
$logoutHtml,
),
));

Related

using Csqldataprovider CGridView and CButtonColumn (Yii Framework) dont appear

i have got a gridview using the Csqldataprovider but then unlike CAtiveDataProvider default cButton column doesnt appear i did write the custom code to it
array(
'class'=>'zii.widgets.grid.CButtonColumn',
'viewButtonUrl'=>'Yii::app()->createUrl("/Controllername/view",array("id"=>$data["mid"]))',
),
as well am not rendering $data["mid"] in the gridview
but yet browser renders
PHP notice
Trying to get property of non-object
...yii\framework\base\CComponent.php(612) : eval()'d code(1)
can anyone tell me what am i missing
try something like this
array(
'class'=>'CButtonColumn',
'buttons'=>array(
'delete'=>array(
'url'=> 'your/ url',
),
'update'=>array(
'url'=> 'your/ url',
),
'view'=>array(
'url'=>'your/ url',
),
),
),
try
array('header'=>'Modifies',
'headerHtmlOptions' => array('style' => 'background-color:#E4E7E8'),
'htmlOptions' => array('style' => 'width:55px'),
'class'=>'zii.widgets.grid.CButtonColumn',
'viewButtonUrl'=>'Yii::app()->createUrl("/account/view", array("id"=>$data["id"]))',
'updateButtonUrl'=>'Yii::app()->createUrl("/account/editDealer", array( "d789#_5%1%d" => $data["id"]))',
'deleteButtonUrl'=>'Yii::app()->createUrl("/account/deleteDealer", array("d!7_#371%d"=>$data["id"]))',
),

How to use javascript:void(0) in menu of yii

How to use javascript:void(0) in menu of yii
<?php $this->widget('zii.widgets.CMenu',array( 'items'=>array( array('label'=>'Home', 'url'=>array('site/funtionname')),), )); ?>
i have tried using like this:-
<?php $this->widget('zii.widgets.CMenu',array( 'items'=>array( array('label'=>'Home', 'url'=>array('javascript:void(0);')),), )); ?>
but its not working...
only 'url'=> 'javascript:void(0);' without using array

yii adding font awesome icons in bootstrap nav bar

I'm trying to add an icon to my bootstrap navbar
this is the icon i'm trying to add <i class="icon-fa-comments icon-3x "></i>
i'm currently using this font awesome extension and this bootstrap extension
the icon shows when it's in my html, but not when i add it to nav bar. any idea what i'm missing? sorry still new to Yii, can't find a key other than label to do what i want. tried htmlOptions but no luck too
<?php
$this->widget('bootstrap.widgets.TbNavbar',array(
'items'=>array(
//'brand' => CHtml::encode(Yii::app()->name), //site name
//'fixed' => true,
array(
'class'=>'bootstrap.widgets.TbMenu',
'items'=>array(
array('label'=>'Home', 'url'=>array('/')),
array('label'=>'About', 'url'=>array('/about')),
array('label'=>'Contact', 'url'=>array('/contact')),
array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->user->name.')', 'visible'=>!Yii::app()->user->isGuest),
),
),
array(
'class'=>'bootstrap.widgets.TbMenu',
'htmlOptions'=>array('class'=>'pull-right'),
'items'=>array(
array('label'=>'<i class="icon-fa-comments icon-3x "></i>', 'url'=>'#'),
array('label'=>'Dropdown', 'url'=>'#', 'items'=>array(
array('label'=>'Action', 'url'=>'#'),
array('label'=>'Another action', 'url'=>'#'),
array('label'=>'Something else here', 'url'=>'#'),
'---',
array('label'=>'Separated link', 'url'=>'#'),
)),
),
),
),
)); ?>
In order to display icons in Yii-2 components like Navbar or Nav, you must set encodeLabels to false.
http://www.yiiframework.com/extension/yii2-icons/
try this
array('icon'=>'icon-fa-comments icon-3x', 'url'=>'#'),
Some times you get squares on the web page although you have added the css file font-awesome.css successfully. The solution is very easy you and need to place the font directory (containing four font files) as well inside the CSS folder where you have placed font-awesome.css.
The font directory contains four other font files.
fontawesome-webfont.eot
fontawesome-webfont.ttf
fontawesome-webfont.woff
FontAwesome.otf
Jay is right but I found the explanation hard to follow, so I am adding the code here. This is what the working solution looks like:
In the php header (presuming you have installed kartik icons)
use kartik\icons\Icon;
Icon::map($this);
...
In the nav widget:
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'encodeLabels' => false, // declaration goes here (before the items)
'items' => [
[
'label' => Icon::show('home',[
'class'=>'your-custom-class-if-needed'
]),
'url' => ['/survey-visits/index'],
'visible' => !Yii::$app->user->isGuest,
],
You can label encoding for individual element like below:
array('label'=>'<i class="icon-fa-comments icon-3x "></i>', 'url'=>'#', 'encode'=>false)

How to set the max size of a log file in YII?

I can see that Yii has "setMaxLogFiles" function here, but I don't know how to use it. I figured you'd be able to just add it in config/main.php, but it doesn't seem there is a place to put it?
I think that it's in your configuration file:
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'trace, info',
'categories'=>'system.*',
),
array(
'class'=>'CEmailLogRoute',
'levels'=>'error, warning',
'emails'=>'admin#example.com',
),
),
),
You can specify some options like the file size or the maximum number of log files:
array(
'class'=>'CFileLogRoute',
'levels'=>'trace, info',
'categories'=>'system.*',
'maxFileSize' => 99999,
'maxLogFiles' => 1,
),
Source: The Yii Guide about logging

yii-user-management install 404 error

I am using MAMP pro with yii-1.1.12. and I am trying to install the latest version of yii-user-management.
My route for the webapp is
/Users/myname/Sites/yii-1.1.12/htdocs
I created the 'modules' folder and copied the yii-user-management into it:
htdocs > protected > modules
(modules and subfolders set to rewrite)
config/main.php
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'password',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
'modules' => array(
'user' => array(
'debug' => true,
)
),
),
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'class' => 'application.modules.user.components.YumWebUser',
'allowAutoLogin'=>true,
'loginUrl' => array('//user/user/login'),
),
'import'=>array(
'application.modules.user.models.*',
),
etc...
I have followed the instructions to the letter but when I call the user/install in the browser I get a 404 error.
http://yii.dev:8888/index.php/user/install
My page works okay http://yii.dev:8888/index.php/login (with or without index.php)
Very frustrating. Any help would be appreciated.
I just realized there's a problem with your config/main.php...
You have modules listed within modules:
'modules'=>array(
'gii'=>array(//...gii configuration...),
'modules' => array(
'user' => array(
'debug' => true,
)
),
It should just be:
'modules'=>array(
'gii'=>array(//...gii configuration...),
'user' => array(
'debug' => true,
)
),