Difference between #8 and #7 of CSS, JS and image URL shortcut methods

unchanged
Title
CSS, JS and image URL shortcut methods
unchanged
Category
Tutorials
unchanged
Tags
URL
changed
Content
Below I have extended the CHtmlcreated an Html helper
to havewith methods thatto help me
locate directories of my assets dynamically. Such assets may include CSS,
JavaScript and images.

~~~
[php]
<?php
class Html extends CHtml
{
	/**
	* Makes the given URL relative to the /image directory
	*/
	public static function imageUrl($url) {
		return Yii::app()->baseUrl.'/images/'.$url;
	}
	/**
	* Makes the given URL relative to the /css directory
	*/
	public static function cssUrl($url) {
		return Yii::app()->baseUrl.'/css/'.$url;
	}
	/**
	* Makes the given URL relative to the /js directory
	*/
	public static function jsUrl($url) {
		return Yii::app()->baseUrl.'/js/'.$url;
	}
}
~~~

Methods like the above can be useful for including assets on the client-side. 
You can use it like in the following:

~~~
[php]
<?php
echo
CHtml::cssFile(Html::cssUrl('reset.css'));Html::cssFile(Html::cssUrl('reset.css'));
echo
CHtml::cssFile(Html::cssUrl('typography.css'));Html::cssFile(Html::cssUrl('typography.css'));
echo
CHtml::cssFile(Html::cssUrl('main.css'));Html::cssFile(Html::cssUrl('main.css'));
echo
CHtml::cssFile(Html::cssUrl('form.css'));Html::cssFile(Html::cssUrl('form.css'));
?>
~~~

This is much cleaner and shorter then prefixing the URLs manually.  Also, if you
ever wish to move the directory of some sort of asset, all you need to do is
modify the corresponding method in Html.

You may note that in the above example, `Html` does not *have* to extend
`CHtml`.  Neither do you have to name the class `Html`.  It's all personal
preference.