Yii Framework Forum: The obscure indent on the page - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

The obscure indent on the page Rate Topic: -----

#1 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 15 July 2010 - 02:19 AM

Hi!

I use some different layouts in my site and I decide to separate the head part into other view header.php:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>

<?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/blueprint/screen.css', 'screen'); ?>
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/blueprint/print.css', 'print'); ?>

<title><?php echo CHtml::encode($this->pageTitle); ?></title>

</head>
<body>

<div class="container">
    <a href="<?php echo Yii::app()->createUrl('/'); ?>" class="span-24 last tw-logotype"></a>


And in my main.php layout I write:
<?php $this->renderPartial('../layouts/header'); ?>
	<div class="span-24 last tw-container">....


But when I did it I see some changes in the page, the strange indent occured in the top of the page. I have the template just like here. Without separated files it looks good, but with one, the inscription "Uploadify" ( "Logo" in my case ) is shifted about 20px to the bottom.

I have no any line breaks or tabulation in both layouts and the source code of the page looks same in both cases.

I dont know with what it may be due. Do you have any ideas?
0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 15 July 2010 - 04:43 AM

Use firebug to inspect the HTML elements. It will show you margin+border+padding for every hovered element. It should help you to find out where the space comes from.

And btw. the "Miscellaneous" section of the forum would be better for questions like these. It's not really Yii related but rather a CSS question. We should keep the forum clean.
0

#3 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 15 July 2010 - 04:57 AM

It's not about css. It's about renderPartial. I use firebug surely. The source code is the same in both cases.
0

#4 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 15 July 2010 - 05:11 AM

Aha, if the source code on the client is really the same as you claim, Yii must do something magic and cast a spell on your browser, to let your browser know, that this same source code has been generated by Yii and needs to be rendered different now ;)

Please check again thoroughly. There must be a difference in source/CSS on the client, otherwhise the rendered result must be the same.
0

#5 User is offline   Junior - df9 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 416
  • Joined: 24-May 09
  • Location:Brazil

Posted 15 July 2010 - 05:20 AM

have you tried using

require_once('path-to-header.php')


is there any difference when you render with require and renderPartial?

regards!
______________________________________
Junior
df9.com.br
Linux Registered User #364954
GNU/Linux: together we're ready!
0

#6 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 15 July 2010 - 06:54 AM

There's one issue i can think about: If a line ends with an close PHP block marker ?> the newline character after it will be removed. So if your layout somehow depends on a newline after <?php $this->renderPartial(...) ?>, make sure, that you add a space character after ?>.
0

#7 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 15 July 2010 - 01:59 PM

I recheck one more time the source code in both cases, ones are absolutely same. I tried to replace the renderPartial by require_once, and add the space character after the end market but it doesn't give the needed effect.

I even tried to use the contentCompactor extension for deleting the line breaks of all content. Now my content is a one line, but it doesn't helps too...

I don't know what is the magic :)
0

#8 User is offline   PoL 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 506
  • Joined: 05-November 08
  • Location:Buenos Aires, Argentina

Posted 15 July 2010 - 02:24 PM

As Mike said, if final result (final html when Yii finish all its work) is the same in both cases, then is imposible that they are rendered diferent by the browser (wich doesnt know if you use one method or another)...
May be we are missunderstanding your problem...
Don't say what you think, think what you say
The problem is communication! Excess of communication!
0

#9 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 16 July 2010 - 01:17 AM

If you can't find the difference manually, download both versions and use some diff tool. If you're on linux try something like this:

# wget 'http://yourhost.com/first.html'
# wget 'http://yourhost.com/second.html'
# diff first.html second.html


Again: If you see a difference in the browser, there has to be a difference in the source. Also check your CSS, maybe you load a different CSS file...

And i keep up my claim: Not really Yii related. This is HTML/CSS debugging ... ;)
1

#10 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 16 July 2010 - 01:32 AM

You are right Mike. It's not visible in the browser. I saved both pages and open ones via Notepad++. Take a look please on printscreens: without renderPartial and with . It's the strange sign in the seven line. How can I delete it?

Forget to say. In this example I include only css and js files. header.php is:
<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/index.js'); ?>
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/blueprint/screen.css', 'screen'); ?>
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/blueprint/print.css', 'print'); ?>
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/self.css'); ?>


and the layout:
<!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">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php $this->renderPartial('../layouts/header'); ?>

<title><?php echo CHtml::encode($this->pageTitle); ?></title>

</head>
<body>

0

#11 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 16 July 2010 - 01:41 AM

First suspect that comes to my mind: BOM. Check again that all your files are proper UTF-8 without BOM.
1

#12 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 16 July 2010 - 01:52 AM

That's what i did, I delete all includes from header.php, it's completely empty now, and then I exclude scrollable plugin. Now I have no any css or js files at all. But even now I have that sign ( printscreen ).

Oops) It was BOM in the header.php :blink:

Thank you Mike!
0

#13 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 16 July 2010 - 01:55 AM

Do you still use renderPartial? Or could you show the top section of your layout now, please?
0

#14 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 16 July 2010 - 01:57 AM

Ah, you already fixed it. Good. :)
0

#15 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 16 July 2010 - 01:59 AM

Even if the BOM in the middle of the page it makes such effect. I fount it in another files. I didn't know about existing the BOM at all. Thanks again :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users