SWF Object insertion View Helper
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 2526 27 28 29 3031 32 33 34 3536 37 38 39 40 | class Custom_View_Helper_SwfObject { function swfObject($name, $params=array(), $module=NULL) { $view = Zend_Layout::getMvcInstance()->getView(); $view->headScript()->appendFile($view->baseUrl().'/scripts/swfobject.js'); $swfPath = $view->baseUrl()."/flash/$name.swf"; $expressInstallPath = $view->baseUrl()."/flash/expressInstall.swf"; $id = 'swf_id_'.str_replace(' ', '_', strtolower($name)); $width = "100%"; $height = "100%"; $version = "9.0.0"; // override all of the above extract($options); $headScript = <<<HEADSCRIPT swfobject.embedSWF("$swfPath", "$id", "$width", "$height", "$version", "$expressInstallPath"); HEADSCRIPT; $view->headScript()->captureStart(); echo $headScript; $view->headScript()->captureEnd(); $flashContainer = <<<FLASHCONTAINER <div id="$id"> <a href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /> </a> <p> You need Adobe Flash Player </p> </div> FLASHCONTAINER; return $flashContainer; } } |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
Inserting flash objects into the page.
It is different than Zend_View_Helper_HtmlFlash because it uses javascript element replacement technique.
it assumes you already use a baseUrl view helper and that your resources(flash files, javascript files) reside in a directory structure like:
styles
- main.css
- reset.css
- etc.css
flash
- swfobject.swf
- expressInstall.swf
- other.swf
- etc.swf
scripts
- swfobject.js
- other.swf
- etc.swf
Snippet details
- Created:
-
iongion
- Edited:
-
iongion
- Revision Id:
- 52
- Edit Message:
- Initial Release
- Tags:
- flash swf swfobject ViewHelper
- Comments:
- 1
- Views:
- 377
- Points:
- 1 (1 votes)
1 year ago
You should use the Google Hosted Library instead:
http://ajax.googleapis.com/ajax/libs/swfobject/2/swfobject.js
More: http://code.google.com/p/swfobject/wiki/hosted_library