[EXTENSION] Bootstrap Bringing together Yii and Twitter Bootstrap
#1
Posted 26 September 2011 - 04:09 AM

POPULAR
This is the discussion thread for my latest extension, Bootstrap.
What is Bootstrap?
Bootstrap is a toolkit to kickstart development of web applications. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation and more. Bootstrap has been developed by Twitter, it is open source and can be found on Github.
Why an extension?
After trying out Bootstrap I immediately decided that it was time to write an extension to allow developers to easily implement this awesome toolkit in their existing and upcoming Yii-projects.
Download the extension here:
http://www.yiiframew...sion/bootstrap/
Fork me Bitbucket:
https://bitbucket.or.../yii-bootstrap/
More about Bootstrap here:
http://twitter.github.com/bootstrap/
Try out the demo here:
http://www.cniska.ne...bootstrap/demo/
Enjoy!
#3
Posted 26 September 2011 - 05:36 AM
Thanks!
#4
Posted 26 September 2011 - 05:51 AM
bigardusklei, on 26 September 2011 - 05:36 AM, said:
Thanks!
I'm actually also using it with LESS but I'm using it trough my own less extension (that I haven't published yet) which uses Agar's LESS compiler, less.php (https://github.com/agar/less.php).
However, I don't see why you couldn't use less.js with the extension. The less-files are included in the less-folder.
Let me know if you run into any issues.
#5
Posted 26 September 2011 - 06:18 AM
The CMenu Widget is already working fine using this layout:
<div class="topbar">
<div class="topbar-inner">
<div class="container">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
...
),
)); ?>
</div>
</div>
</div>But it would even be cooler using a Widget. I think about something like this:
$this->widget('ext.bootstrap.widgets.topbar',array(
'items'=>array( ... ) );
Of course, you do not always ONLY want a Menu in there. For example, you want infos about
the current logged in user, a search input field, and so-on. This could be accomplished
by something like this:
$this->widget('ext.bootstrap.widgets.topbar',array(
array(
'class' => 'CMenu',
'items' => ...
),
array(
'class' => 'Searchbox' // render a search box
),
array(
'class' => 'UserInfo' // render info about the current logged in user
'template' => Yii::t('You are currently logged in as {username}', array('{username}' => $user)),
),
),
What do you think?
Edit: with a little bit of adjustment i also got the drop-down menu working. Nice !
Would also go into the navbar extension. "secondary nav" is also supported by bootstrap!
#6
Posted 26 September 2011 - 06:54 AM
Edit: Another solution could be to use a template string to achieve this.
Any thoughts about the extension in general?
#7
Posted 26 September 2011 - 12:31 PM
Chris83, on 26 September 2011 - 06:54 AM, said:
The extension in general Rocks!
Especially i like the BootActiveForm and the one-liner-widgets xxxxBlock Widgets. They
make form building even easier and quicker than the standard CActiveForm.
I will make a "topbar" widget. The template string is a very good idea, i will do it this way. I post it as soon as it is done
for you to check.
Another idea would be to do 'gii' templates that generate ready-to-use BootActiveForm _form.php files.
#8
Posted 26 September 2011 - 05:23 PM
Please let me know if this works for you.
Usage _should_ be self-explanatory - but if you are going to include this in your bootstrap package i will write
examples and Documentation for it...
Attached File(s)
-
BootTopbar.php (6.26K)
Number of downloads: 90
#9
Posted 27 September 2011 - 01:05 AM
#10
Posted 27 September 2011 - 02:13 AM
css classes need to be appended to the <ul> and <li>. Also a <a> with a special class needs to be assigned.
This is not possible with the vanilla CMenu. And i did not want a special Class just for the Menu. Moving
these few functions into the widget should do it, i think.
So it could extend from CWidget, thats true
Of course, if you got a better approach with separate widgets, i would glad use them.
Until then i stick to my approach.
#12
Posted 27 September 2011 - 06:06 AM
Totally needed for a totally non-designer like me.
#13
Posted 03 October 2011 - 04:06 AM
Version 0.9.1 is now live:
http://www.yiiframew...trap-0.9.1.zip/
What's new?
- BootFlash (flash message widget)
- BootstrapGenerator (Gii CRUD templates)
- Various improvements to BootActiveForm
Enjoy!
Please note that the BootGridView has been moved into the following sub-package:
ext.bootstrap.widgets.grid
#14
Posted 06 October 2011 - 03:48 PM
The "single line of code" is cool, but sometime it cannot be very flexible
EDIT: Looking at the code it seems it is possible. Now I have to find out how to pass $label=false from view
#15
Posted 07 October 2011 - 12:56 AM
zitter, on 06 October 2011 - 03:48 PM, said:
The "single line of code" is cool, but sometime it cannot be very flexible
EDIT: Looking at the code it seems it is possible. Now I have to find out how to pass $label=false from view
The idea with the one-line widget was to only cover the most common cases, so in your case I would just write the code the old fashion way.
#16
Posted 12 October 2011 - 05:14 AM
https://bitbucket.or...3/yii-bootstrap
Feel free to send me pull requests and I will review your patch to see if it should be merged into the master branch.
Bootstrap can also be found on Ohloh so please go tell Ohloh if you use this project by pressing the "I USE THIS" button.
https://www.ohloh.net/p/yii-bootstrap
#17
Posted 12 October 2011 - 10:21 AM
I want to see a twipsy tip on some input form element on focus event, but jquery.boottwipsy.js does not take into account a "trigger" option.
Also the default $selector is '.twipsy', but bootstrap.min.css has declared class .twipsy in it. So when I add this class to any form input element, I see that font decrease to 11px.
#18
Posted 12 October 2011 - 03:31 PM
lehandr, on 12 October 2011 - 10:21 AM, said:
I want to see a twipsy tip on some input form element on focus event, but jquery.boottwipsy.js does not take into account a "trigger" option.
Also the default $selector is '.twipsy', but bootstrap.min.css has declared class .twipsy in it. So when I add this class to any form input element, I see that font decrease to 11px.
@lehandr: Twipsy was originally only meant for links but I can see why you'd like to have it on a focus event. I have to think about adding the functionality when I have time. Regarding your selector issue, you have two options. You can either specify the selector yourself by giving it as an "argument" to the widget or you can override the .twipsy class in your own CSS.
#19
Posted 13 October 2011 - 08:50 AM
When I use CActiveFrom I set:
<?php
$form=$this->beginWidget('CActiveForm', array(
...
'enableAjaxValidation'=>true,
...
)) ?>
and on the fields that not required ajax validation:
<?php echo $form->error($model,$attribute,array(),false); ?>
where the last parameter false allow to disable ajax validation for field.
I saw in the BootInputBlock::run() to line 105:
$error = $this->form->error($this->model, $this->attribute);
So when I use BootActiveForm I have not a possibility to disable ajax validation for some fields.
Is there another decision to resolve it or maybe all error's parameters can be added to all inputBlock methods in the next releases?
#20
Posted 13 October 2011 - 09:04 AM

Help












