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)
Related
What I want to achieve Image! Hi I am working on a module in prestashop. What I want is that there should be a button (any-name: Add new field) in the backoffice-(Module Configuration page the first page that comes when you configure your module) that the user presses and it should add a new input field in the form. This all should be done using the helper classes. How can I achieve that? Some code would be grateful! I have uploaded an image. I have tried it using jQuery and it works but I need this done using helperForms in prestashop! In jQuery if I press the add new field button it adds an input field dynamically but the helper-classes are not used in that case.
Here is a link to the documentation :
http://doc.prestashop.com/display/PS16/Using+the+Helper+classes
the documentation is for PS 1.6 but it should also work with PS 1.7
Here is an example of code that generate a form with Helper Classes :
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Edit carrier'),
'image' => '../img/admin/icon_to_display.gif'
),
'input' => array(
array(
'type' => 'text',
'name' => 'shipping_method',
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right'
)
);
I don’t know if you can use Helper class for custom forms that update custom datas. I’m sure you can use them to update module configuration and prestashop object (customer, etc.)
Helper classes enable you to generate standard HTML elements for the
back office as well as for module configuration pages.
When I use Kartik ExportMenu widget in my code, all dropdown stop working..
Here's a sample of code I am using,
echo ExportMenu::widget([ 'dataProvider' => $dataProvider, 'columns' => $gridColumns ]);
the widget is affecting only that single page, dropdowns on other pages are working..
After some Googling, I found that its conflicting with bootstrap js file.. which I am including in my Asset 'bootstrap.min.js',
if I remove bootstrap.min.js, obviously.. all dropdown should stop working.. but the dropdown on the page I have widget are working..
In my project I need to use both of them...
Is there any solution, anyone can think off??
for that use unset concept in that particular page.
add following lines at the end of your code.
<?php unset($this->assetBundles['yii\bootstrap\BootstrapAsset']); ?>
Add a showColumnSelector to the widget options and assign value true to it. as in:
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns'=>$gridColumn,'showColumnSelector' => \true,
]);
I've installed Yii2 together with Smarty for my views.
Smarty itself is working, but I can't figure out how to use the bootstrap widgets with smarty, nor find any examples.
With the default Yii renderer the widgets work great, and lots of examples are available. But when using Smarty templates documentation is nearly non existing.
How would I define this example with Smarty ?
echo Alert::widget([
'options' => [
'class' => 'alert-info',
],
'body' => 'Alert widget',
]);
Obviously the first thing would be
{use class="yii\bootstrap\Alert"}
But I can't find an example of how to define the widget itself.
You should simply try this :
{use class='#yii\bootstrap\Alert' type='function'}
{Alert body='Alert widget' options=['class' => 'alert-info']}
Read more : http://www.yiiframework.com/doc-2.0/guide-tutorial-template-engines.html#importing-static-classes-using-widgets-as-functions-and-blocks
After changing config/web.php and adding:
'globals' => ['html' => '\yii\helpers\Html'],
'uses' => ['yii\bootstrap'],
in the view section, it works.
{use class='yii\bootstrap\Alert' type='function'}
{Alert body='Alert' options=['class' => 'alert-info']}
So without the # soju suggested.
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"]))',
),
I have mess all day with this decorator, i read many source to implement dojo tab container via zend framework, but i tried it self result nothing.
is there any misscode with this snippet
$form = new Zend_Dojo_Form();
$form->setName('name')
->setLegend('legend')
;
$form->setDecorators(array(
'formElements',
array('tabContainer', array(
'id' => 'tabContainer',
'style' => 'width: 600px; height: 500px;',
'dijitParams' => array(
'tabPosition' => 'top'
),
)),
'DijitForm',
));
$a = new Zend_Dojo_Form_Element_TimeTextBox('time');
$a->setLabel('label');
$sf = new Zend_Dojo_Form_SubForm();
$sf->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'dl')),
'ContentPane',
));
$sf->addElement($a);
$form->addSubForm($sf, 'subform');
thanks before
this?
or this?
Dojo view helpers in Zend use captureStart() and captureEnd()