Jonathon Posted April 2, 2013 Share Posted April 2, 2013 I actually built my demo site without using any bootstrap extensions. So this chapter I am looking forward to reading. This is currently how my code is set up config/main.php // application components 'components'=>array( 'bootstrap' => array( 'class' => 'ext.bootstrap.components.Bootstrap', 'responsiveCss'=>true, ), layout/main.php <div class="nav-collapse collapse"> <?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('/site/login'), 'visible'=>Yii::app()->user->isGuest), array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'),'visible'=>!Yii::app()->user->isGuest), ), 'htmlOptions' => array('class'=>'nav') )); ?> </div><!--/.nav-collapse --> When I load my page. I don't have a lovely boostrap bar. I don't seem to have any boostrap files brought in or anything either. So I then thought i'd try the breadcrumb part out. Now this throws the following error: Alias "bootstrap.widgets.TbBreadcrumbs" is invalid. Make sure it points to an existing directory or file. So i'm deducing that somewhere along the way I have an incorrect directory path. That may be wrong, but wondered if anyone could shed some light. I will continue to try and get to the bottom of this. I've also checked my permissions on Windows 7. Normally I don't think they are very strict however. Link to comment Share on other sites More sharing options...
Edward Posted April 2, 2013 Share Posted April 2, 2013 I am confused also with this, usually with YiiBooster a basic navbar wood be implemented by adding the code like i done below. Are you sure its not bootstrap when you call the widget and not zii? $this->widget('bootstrap.widgets.TbNavbar', array( 'brand' => 'Title', 'items' => array( array( 'class' => 'bootstrap.widgets.TbMenu', 'items' => array( array('label'=>'Home', 'url'=>'#', 'active'=>true), array('label'=>'Link', 'url'=>'#'), array('label'=>'Link', 'url'=>'#'), ) ) ) )); http://yii-booster.clevertech.biz/components.html#navbar Link to comment Share on other sites More sharing options...
Larry Posted April 2, 2013 Share Posted April 2, 2013 Sorry guys. I screwed up! You need to add "bootstrap" to the "preload" section of the config file, too. I'll send out a correction on this. Link to comment Share on other sites More sharing options...
Edward Posted April 2, 2013 Share Posted April 2, 2013 I did have that // preloading 'log' component 'preload'=>array('bootstrap','log'), but the css would not draw properly the way you wrote it. Link to comment Share on other sites More sharing options...
Larry Posted April 2, 2013 Share Posted April 2, 2013 Either way. You can use the YiiBooster widget. I used the Zii widget and added the class to the htmlOptions. Link to comment Share on other sites More sharing options...
Edward Posted April 2, 2013 Share Posted April 2, 2013 I think i know what you mean, i have been working with YiiBooster today on other stuff, its certainly a big time saver. One thing though, should we go to change the main Yii layout files, main.php, column1.php and column2.php to the Boostrap css layouts. I did do this before but wondered if i should do this again? The only thing i could see we were taking out was the Page ID tag, which takes out some marginal padding, its nothing we couldn't add in ourselves. Link to comment Share on other sites More sharing options...
Jonathon Posted April 2, 2013 Author Share Posted April 2, 2013 Thanks for the help Larry. That fixed it. As a side note though. I had to use the YiiBooster widget to get the nav bar to display properly. Link to comment Share on other sites More sharing options...
Larry Posted April 2, 2013 Share Posted April 2, 2013 Here's the code I used to create the nav bar: <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="brand" href="index.php">Project name</a> <div class="nav-collapse collapse"> <?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('/site/login'), 'visible'=>Yii::app()->user->isGuest), array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest), ), 'htmlOptions' => array('class'=>'nav') )); ?> </div><!--/.nav-collapse --> </div> </div> </div> I took the code from the TB starter template, posted in the CMenu widget in the right place, and added the "nav" class. 1 Link to comment Share on other sites More sharing options...
Larry Posted April 2, 2013 Share Posted April 2, 2013 And to answer Edward's question, I crated a new layout file named "bootstrap.php", then set Controller.php to use it. Link to comment Share on other sites More sharing options...
Edward Posted April 3, 2013 Share Posted April 3, 2013 Thanks that was useful Larry, i will do it that way. One last thing, we can edit our main css from main.php in the layouts folder but what if we wanted to have some pages fixed width and other pages with fluid width. How would you personally go about handling such a situation in Yii? Also did you get my comment in YiiBook thread regarding the setting in the main.php config file, i couldn't find that mentioned in the book. Link to comment Share on other sites More sharing options...
Larry Posted April 3, 2013 Share Posted April 3, 2013 It sounds like you'd use two different layout files in that situation. I did see your comment and I'll look into that. Thanks for pointing it out! Link to comment Share on other sites More sharing options...
Recommended Posts