The obscure indent on the page

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?

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.

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

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.

have you tried using




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



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

regards!

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

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 :)

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…

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 … ;)

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>

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

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!

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

Ah, you already fixed it. Good. :)

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 :)