Jump to content
Larry Ullman's Book Forums

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.
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

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.

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
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.

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.
Note: Your post will require moderator approval before it will be visible.

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...
×
×
  • Create New...