Jump to content
Larry Ullman's Book Forums

Yii Css Issue


Recommended Posts

I am trying to work the yii CSS layout into my example. But with one of my pages it is wider than the other. Please see below the yii main.php in layouts folder. I am trying to find a division block <div id="content"> as they do have it mentioned in their main.css file




padding: 20px;



but i don't understand quite where in yii this is coming up or used, all i can see on the main layouts sheet is the <?php echo $content; ?>.


But on one of the view's files i still can't find the content id being shown in a devision block, so is it somewhere else?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<!-- blueprint CSS framework -->
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
<div class="container" id="page">
<div id="header">
 <div id="logo"><?php echo CHtml::encode(Yii::app()->name); ?></div>
</div><!-- header -->
<div id="mainmenu">
 <?php $this->widget('zii.widgets.CMenu',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)
 )); ?>
</div><!-- mainmenu -->
<?php if(isset($this->breadcrumbs)):?>
 <?php $this->widget('zii.widgets.CBreadcrumbs', array(
 )); ?><!-- breadcrumbs -->
<?php endif?>
<?php echo $content; ?>
<div class="clear"></div>
<div id="footer">
 Copyright © <?php echo date('Y'); ?> YiiCustomized.com
</div><!-- footer -->
</div><!-- page -->

Link to comment
Share on other sites

I was thinking about that new book of yours Larry but it might be too late now, if you build up an oop mvc from scratch in the book to show how the whole thing worked, i don't think there would be any better example. I have another php book with one in but i couldn't understand it.

Link to comment
Share on other sites

  • Chapter 9: Example–CMS with OOP
    • Identifying the Goals
    • Creating the Database
    • Making the Template
    • Writing a Utilities File
    • Creating the Error View File
    • Defining the Classes
    • Creating the Home Page
    • Viewing a Page
    • Using HTML_QuickForm2
    • Logging Out
    • Adding Pages

Is it this chapter, is that your own MVC object-orientated framework? The book looks like it will be a good one, nothing on how to handle the stress of how to handle css related problems? :)

Link to comment
Share on other sites

CSS and PHP are generally divided into the loose categories front-end and back-end programming. They are usually done by people with different jobs, following that each job generally is done by different sides of the brain. The ones with a more active left-sided, logical parts, is generally the programmer. The right sided, creative ones is more often doing design and therefor also CSS. This is a very general statements on my part. (And I don't mean to offend, only explain)


While many do both, they are not related per se. This is also the reason while patterns like MVC is generally preferred inside larges companies. It allows programmers, designers and database experts to develop alongside each other. Because each job requires different skills, and specialization is preferred in each field, it allows you to dive the parts in development.


This is also why you see little CSS/design in programming books. They are different fields, and books have limited space. I would instead recommend you to find books about CSS/Html to learn about this. :)


Hope that makes sense. It's hard for me to explain such topics in English and keep track of the nuances. As I said, I only mean to explain.

  • Upvote 1
Link to comment
Share on other sites

That's a good explanation Antonio, now i know why i was getting more headaches than usual, all that stress on the left and right side. I have a few glitches in my CSS, someone is wrong here, it could be blueprints, it could be Yii, or it could be me, but its probably me, haha. I am building my site the normal way now but in a reasonably good css, its actually looking much better than i had expected. I am going to change to the MVC later on, i know there are others that have dived into MVC and frameworks, later forgetting the basics and getting suck, at least if we build the normal way it will be done. I have some of the best CSS books you can get if you want to know, but how can i get the chance to read them with all the time the coding takes. Ive been taking parts of of PHP & MySQL 4th edition, parts out of Knowledge is Power from Effortless Eccommerce, everything has to be changed. And those form help functions, i am debating over whether they are going to be necessary as there is much more detail in these input tags than in the book.

Link to comment
Share on other sites

Yes, that's the chapter. But it's not really an MVC framework. It's just a similar MVC division of labor as I also use in the second example of the e-commerce book. I don't discuss CSS but there aren't any "css related problems".

Link to comment
Share on other sites

Oh right, I did take a look at coffee shop and I could understand what you were doing there with MVC. What I don't like is using someones framework without really understanding how the underlying code is working. I noticed how frameworks load up with a bootstrap always load through index.php then route to the php page you are on. Right now that is all I know but would like to know more before I start using one.


Like Antonio said MVC's would be used by larger companies so different skilled employies could work on different parts of the site at the same time. But for what I need to do for now the normal way of logic, view and model on the same page is fine.

Link to comment
Share on other sites


  • Create New...