Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Jonathon

Yiibooster Problem

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

I did have that

 

// preloading 'log' component
    'preload'=>array('bootstrap','log'),

 

but the css would not draw properly the way you wrote it.

Share this post


Link to post
Share on other sites

Either way. You can use the YiiBooster widget. I used the Zii widget and added the class to the htmlOptions.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.
  • Upvote 1

Share this post


Link to post
Share on other sites

And to answer Edward's question, I crated a new layout file named "bootstrap.php", then set Controller.php to use it.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...