[EXTENSION] Bootstrap Bringing together Yii and Twitter Bootstrap
#702
Posted 18 September 2012 - 09:32 AM
Anyone can help me?
Error: Alias "ext.bootstrap.components.Bootstrap" is invalid. Make sure it points to an existing PHP file and the file is readable.
I unzip the extension in the directory: \protected\extensions\bootstrap
Main.php:
Quote
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Supplier Quality Management',
'preload'=>array(
'log',
'bootstrap',
),
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=>array(
'gii'=>array(
'generatorPaths'=>array(
'bootstrap.gii',
),
),
),
'components'=>array(
'bootstrap'=>array(
'class'=>'ext.bootstrap.components.Bootstrap',
),
'user'=>array(
'allowAutoLogin'=>false,
'loginUrl'=>array('site/login'),
),
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=sqm',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
'errorHandler'=>array(
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
),
),
),
'params'=>array(
'adminEmail'=>'webmaster@example.com',
),
);
Thanks!
Diego Rodrigo
#703
Posted 18 September 2012 - 09:44 AM
However I cannot figure out how to display more than 10 records, and to display some navigation buttons to go to the next X(10) records.
I suspect this might be related to my limited knowledge on YII, but it looks trivial so I hope someone will be kind enough to help a newbie.Thanks.
Using Yii as the framework of choice.
#704
Posted 18 September 2012 - 11:04 AM
I have TbButtonColumn in TbGridView.
Is it possible to use popover behavior with buttons in this column?
I have try different ways
<?php $this->widget('bootstrap.widgets.TbGridView', array( 'type'=>'striped bordered condensed', 'dataProvider'=>$userHistory, 'template'=>"{items}", 'columns'=>array( array('header'=>'#', 'name'=>'id'), ... //1st way array( 'header'=>'Test', 'type'=>'html', 'value'=>"$this->widget( 'bootstrap.widgets.TbButton', array( 'label'=>'Click me', 'type'=>'danger', 'htmlOptions'=>array( 'data-title'=>'A Title', 'data-content'=>'And here\'s some amazing content. It\'s very engaging. right?', 'rel'=>'popover' ), ) )" ), //2nd way array( 'header'=>'Actions', 'class'=>'bootstrap.widgets.TbButtonColumn', 'htmlOptions'=>array('style'=>'width: 50px; text-align: center;'), 'template'=>'{info}', 'buttons'=>array( 'info' => array( 'label'=>'Info', 'icon'=>'info-sign', 'url'=>'"#"', 'htmlOptions'=>array('data-title'=>'A Title', 'data-content'=>'And here\'s some amazing content. It\'s very engaging. right?', 'rel'=>'popover'), ), ), ), ) ));
1st way gives me "Property "SomeController.widget" is not defined."
2nd doesn't give me any result. Botton steal have tooltip behavior

#705
Posted 18 September 2012 - 04:37 PM
<?php $this->widget('bootstrap.widgets.TbTypeahead', array( 'model' => Department::model(), 'attribute' => 'department_name', 'options'=>array( 'items'=>4, 'matcher'=>"js:function(item) { return ~item.toLowerCase().indexOf(this.query.toLowerCase()); }", ), )); ?>
#706
Posted 19 September 2012 - 08:55 AM
Have you had problems with render error messages when the forms are validated by AJAX?
How to solve?
#707
Posted 20 September 2012 - 01:33 AM
I may repeat, but I have a problem. The fact is that when I use the Cyrillic cp1251 in yii-bootstrap (whether in the menus, buttons), the words disappear. I set utf-8 encoding. In other words, it does not work in Cyrillic UTF-8.
Thanks in advance!
#708
Posted 20 September 2012 - 04:30 AM
Don Felipe, on 16 September 2012 - 10:31 PM, said:
Make sure it's where it's supposed to be; e.g.
/path-to-webapp/protected/extensions/bootstrap/widgets/TbNavbar.php
Are you still using an older version/download of yii-bootstrap? Then you don't have TbNavbar.php but BootNavbar.php. That would result in above error message; or of course any type of misspelling. Good luck!
Hey,you were right,i only have BootNavbar.php,is it the old version or the newest?,because i used the one i `ve found at www{dot}cniska{dot}net{slash}yii-bootstrap thanks a lot,its good to belong to community!
#709
Posted 20 September 2012 - 04:57 AM
spidaboy, on 20 September 2012 - 04:30 AM, said:
Please use one of the downloads on the right hand side of this link.
yii-bootstrap-1.x => widgets.Tb... (new)
yii-bootstrap-0.9.x => widgets.Boot... (old)
The 1.x versions are not backward compatible! As of now there is no reason to use the older version when starting a new project, so please use 1.1. If you update a existing webapp from 0.9 to 1.x simply search and replace all .php files under /protected and replace "bootstrap.widgets.Boot" with "bootstrap.widgets.Tb".
#710
Posted 20 September 2012 - 06:54 AM
Lothor, on 19 September 2012 - 08:55 AM, said:
Have you had problems with render error messages when the forms are validated by AJAX?
How to solve?
For some reason unknown to me, the errors returned by performAjaxValidation are not listed on the forms that use ajaxSubmit the end of the request.
To solve this, I created the following function:
function showAjaxValidationMessages(response) { for (idInput in response) { while(response[idInput]) { $('#' + idInput + '_em_').empty().html(response[idInput][0]).fadeIn('low'); break; } } }
In ajaxOptions:
'ajaxOptions' => array( 'dataType' => 'json', 'success' => "function(response) { showAjaxValidationMessages(response); }", ),
#711
Posted 20 September 2012 - 07:53 PM
akimoff, on 20 September 2012 - 01:33 AM, said:
I may repeat, but I have a problem. The fact is that when I use the Cyrillic cp1251 in yii-bootstrap (whether in the menus, buttons), the words disappear. I set utf-8 encoding. In other words, it does not work in Cyrillic UTF-8.
Thanks in advance!
i set Yii::app()->charset='cp1251'; in view, but its not worked when i set charset value in config
#712
Posted 24 September 2012 - 10:10 AM
<?php $this->widget('bootstrap.widgets.TbNavbar', array( 'type'=>'inverse', // null or 'inverse' 'brand'=>'CODEPAC', 'brandUrl'=>'#', 'collapse'=>true, // requires bootstrap-responsive.css 'items'=>array( array( 'class'=>'bootstrap.widgets.TbMenu', 'items'=>array( array('label'=>'Home','url'=>array('/site/index'), 'active'=>true), array('label'=>'About', 'url'=>array('/site/page')), array('label'=>'Contact us','url'=>array('/site/contact')), ), ), '<form class="navbar-search pull-left" action=""><input type="text" class="search-query span2" placeholder="Search"></form>', array( 'class'=>'bootstrap.widgets.TbMenu', 'htmlOptions'=>array('class'=>'pull-right'), 'items'=>array( array('label'=>'Sign in', 'url'=>'/user/auth','visible'=>Yii::app()->user->isGuest), '---', [b] array('label'=>'Profile', 'url'=>'/user/user','visible'=>!Yii::app()->user->isGuest, 'items'=>array([/b] [b]array('label'=>'Settings', 'url'=>'user/user/index'),[/b] [b]array('label'=>'Logout', 'url'=>'user/user/logout')[/b], )), ), ), ),
the three last line are the ones that are causing problem,when i try to access those links after clicking on home,page,contact us(using the Site controller actions that are auto-generated by the Yii) the route is appended to the existing url in stead of creating a new url to the module,for example if am on home page(after clicking home it has this as url http:localhost/mysite/index.php/site/index)it gives me this url http://localhost/mys...r/user/index,if i go the same link again with this as url it gives me http://localhost/mys...user/user/index if i click again it add another one again and again..but the strange in all is that it works fine with CMenu,here is snippet of CMenu that works fine,
<?php $this->widget('zii.widgets.CMenu',array( 'items'=>array( array('label'=>'Home', 'url'=>array('/site/index')), array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')), array('label'=>'Contact', 'url'=>array('/site/contact')), array('label'=>'Login', 'url'=>array('//user/auth'), 'visible'=>Yii::app()->user->isGuest), array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('//user/user/logout'), 'visible'=>!Yii::app()->user->isGuest), array('label'=>'My profile ', 'url'=>array('/user/user/'), 'visible'=>!Yii::app()->user->isGuest), ), )); ?>
i am assuming that it might be caused by the fact that those links are submenu but i am not sure since the first in those links is not submenu and has the same problem!thank you again
#713
Posted 24 September 2012 - 12:15 PM
uhm, there's a huge difference between:
'url'=>array('/site/faq') 'url'=>array('site/faq') 'url'=>'/site/faq' 'url'=>'site/faq'
the first 2 will look for a controller route -defined as rules of the urlManager in main config.php- and return an absolute link. you can also easily append additional ids (url parameter) this way.
the latter 2 will treat 'url' as a simple string, and the value will be returned without any change.
<a href="/site/faq">
<a href="site/faq">
it should be obvious by now why some of your links don't work. the leading '/' is missing. when you're in '/site/faq' and click on 'site/faq' the browser will request '/site/site/faq' and so on and on.
hope it helps. it's already late here and i'm too tired for typing.
---edited/added next morning---
here's some basic info about URL management in Yii:
CHtml::link
CHtml::normalizeUrl
CController::createUrl
and
URL Management
have a nice day!
#714
Posted 25 September 2012 - 07:17 AM
#715
Posted 25 September 2012 - 12:55 PM
Anyone can help me?
Error: Alias "ext.bootstrap.components.Bootstrap" is invalid. Make sure it points to an existing PHP file and the file is readable.
I unzip the extension in the directory: \protected\extensions\bootstrap
Main.php: <?php return array( 'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..', 'name'=>'Supplier Quality Management', 'preload'=>array( 'log', 'bootstrap', ), 'import'=>array( 'application.models.*', 'application.components.*', ), 'modules'=>array( 'gii'=>array( 'generatorPaths'=>array( 'bootstrap.gii', ), ), ), 'components'=>array( 'bootstrap'=>array( 'class'=>'ext.bootstrap.components.Bootstrap', ), 'user'=>array( 'allowAutoLogin'=>false, 'loginUrl'=>array('site/login'), ), 'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=sqm', 'emulatePrepare' => true, 'username' => 'root', 'password' => '', 'charset' => 'utf8', ), 'errorHandler'=>array( 'errorAction'=>'site/error', ), 'log'=>array( 'class'=>'CLogRouter', 'routes'=>array( array( 'class'=>'CFileLogRoute', 'levels'=>'error, warning', ), ), ), ), 'params'=>array( 'adminEmail'=>'webmaster@example.com', ), );
Thanks!
Diego Rodrigo
#716
Posted 26 September 2012 - 04:13 AM
#717
Posted 26 September 2012 - 05:37 AM
spidaboy7, on 26 September 2012 - 04:13 AM, said:
i'm very stupid!!!
i had done the download on bootstrap site, not the yii extension, now it's working!
Thanks a lot!!
#718
Posted 26 September 2012 - 08:14 AM
#719
Posted 27 September 2012 - 07:14 AM
<?php $this->beginClip('searchBtn'); $this->widget('bootstrap.widgets.TbButton', array( 'icon'=>'icon-search', 'type'=>'info', 'url'=>'#lookupModal', 'htmlOptions'=>array( 'rel'=>'popover', 'data-toggle'=>'modal') )); $this->endClip(); ?> <?php echo $form->textFieldRow($model, 'memberName', array( 'class'=>'span5', 'readonly'=>true, 'append'=>$this->clips['searchBtn'], )); ?>
All this does is to render the button in a text add-on area. What I want is for the button to be appended directly to the input.
Can anybody help me with this?
Thanks!
#720
Posted 27 September 2012 - 08:42 AM
Timbo, on 27 September 2012 - 07:14 AM, said:
Timbo, your approach is too complicated. Just render the 2 elements as usual and put a div around it.
Something like this... (untested but should work)
<div class="input-append"> <?php echo $form->textFieldRow($model, 'attribute', array('class'=>'input-medium')); ?> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'button', 'label'=>'Go')); ?> </div>
If you need another input or button just put another widget inside the parent div. If you want to get rid of the annoying label of the input (yes you do); the answer can be found in a previous post above and not so long ago.
Cheers,
DF