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

Revision #8 has been created by jonah on Jun 30, 2012, 4:45:25 PM with the memo:

Html no longer extends CHtml
« previous (#7)

Changes

Title unchanged

CSS, JS and image URL shortcut methods

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

URL

Content changed

Below I have extended the Ccreated an Html helper to havewith methods thato help me locate directories of my assets dynamically. Such assets may include CSS, JavaScript and images. ```php <?php class Html extends CHtml
{
/**
[...]
```php
<?php
echo
CHtml::cssFile(Html::cssUrl('reset.css')); echo CHtml::cssFile(Html::cssUrl('typography.css')); echo CHtml::cssFile(Html::cssUrl('main.css')); echo CHtml::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.
 
2 1
4 followers
Viewed: 36 801 times
Version: 1.1
Category: Tutorials
Tags: URL
Written by: jonah
Last updated by: jonah
Created on: Sep 2, 2009
Last updated: 11 years ago
Update Article

Revisions

View all history