CDN View Helper
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 | class Galahad_View_Helper_Cdn extends Zend_View_Helper_Abstract { static $_types = array( 'default' => '', 'images' => '/images', 'styles' => '/styles', 'scripts' => '/scripts', ); static function setTypes($types) { self::$_types = $types; } public function cdn($type = 'default') { if (!isset(self::$_types[$type])) { throw new Exception('No CDN set for resource type ' . $type); } return self::$_types[$type]; } } |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
Setup:
$types = array(
'images' => 'http://me.cachefly.net/images',
'styles' => 'http://static.me.com/st',
'scripts' => 'http://s3.amazonaws.com/mescripts',
);
Galahad_View_Helper_Cdn::setTypes($types);
$view->addHelperPath('Galahad/View/Helper', 'Galahad_View_Helper');
In View/Layout File:
<img src="<?=$this->cdn('images')?>/myimg.png" />
Snippet details
- Created:
-
inxilpro
- Edited:
-
inxilpro
- Revision Id:
- 106
- Edit Message:
- Initial Release
- Tags:
- view helper cdn
- Comments:
- 0
- Views:
- 164
- Points:
- 0 (2 votes)