GSTAR
(Omzy83)
November 26, 2009, 2:44pm
1
When I use the cssFile helper function to insert CSS files, they don’t get separated by line breaks.
For example:
<?php echo CHtml::cssFile('/css/reset.css', 'all'); ?>
<?php echo CHtml::cssFile('/css/style.css', 'all'); ?>
results in:
<link rel="stylesheet" type="text/css" href="/css/reset.css" media="all" /><link rel="stylesheet" type="text/css" href="/css/style.css" media="all" />
It should output on two seperate lines.
mikl
(Mike)
November 26, 2009, 2:46pm
2
That’s common PHP behavior. Check this:
<?php echo "a" ?>
<?php echo "b" ?>
Besides that i don’t really understand why this should matter …
GSTAR
(Omzy83)
November 26, 2009, 2:51pm
3
Oh ok lol. It’s just to make the html output look more structured/neater
seb
(Serebrov)
November 26, 2009, 2:51pm
4
When I use the cssFile helper function to insert CSS files, they don’t get separated by line breaks.
For example:
<?php echo CHtml::cssFile('/css/reset.css', 'all'); ?>
<?php echo CHtml::cssFile('/css/style.css', 'all'); ?>
results in:
<link rel="stylesheet" type="text/css" href="/css/reset.css" media="all" /><link rel="stylesheet" type="text/css" href="/css/style.css" media="all" />
It should output on two seperate lines.
It is better to use Yii::app()->clientScript->registerCssFile().
And CHtml::cssFile only generates HTML code and returns simple string and if you subsequently doing echo for two strings then you will get no line breaks.
bsander
(Sanderb)
November 26, 2009, 2:52pm
5
Yeah PHP eats any linebreak right after its closing tag. If you really care about this, add an extra newline in your source:
<?php echo CHtml::cssFile('/css/reset.css', 'all'); ?>
<?php echo CHtml::cssFile('/css/style.css', 'all'); ?>
or even
<?php echo CHtml::cssFile('/css/reset.css', 'all'), "\n"; ?>
<?php echo CHtml::cssFile('/css/style.css', 'all'), "\n"; ?>
I can’t really see why it matters though.
mikl
(Mike)
November 26, 2009, 2:54pm
6
Or you add a space after the closing tag at the end of the first line…
GSTAR
(Omzy83)
November 26, 2009, 2:57pm
7
seb:
It is better to use Yii::app()->clientScript->registerCssFile().
And CHtml::cssFile only generates HTML code and returns simple string and if you subsequently doing echo for two strings then you will get no line breaks.
What difference does using registerCssFile() make?
seb
(Serebrov)
November 26, 2009, 3:19pm
8
It will add css links to page head and also separated with line breaks .