daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Asset Manager
  2. Goal: To easily include and manage assets (js, css, etc) for a web application.
  3.  
  4. Example: xbreadcrumbs package files..
  5. ./public/assets/xbreadcrumbs/images/separator.gif
  6. ./public/assets/xbreadcrumbs/images/home.gif
  7. ./public/assets/xbreadcrumbs/xbreadcrumbs.css
  8. ./public/assets/xbreadcrumbs/xbreadcrumbs.js
  9. # our custom files (explained below)
  10. ./public/assets/xbreadcrumbs/custom.css
  11. ./public/assets/xbreadcrumbs/onload.js
  12. ./public/assets/xbreadcrumbs/config.php
  13.  
  14. ----
  15.  
  16. File: ./assets/xbreadcrumbs/config.php
  17. This provides a fluent interface to add CSS/JS files that will append </HEAD> using Zend's head* view helpers...
  18. <?php
  19. $assetManager->addCssFile('xbreadcrumbs.css');
  20. $assetManager->addCssFile('custom.css'); // override classes, add custom styles, etc
  21. $assetManager->addJsFile('xbreadcrumbs.js');
  22. ?>
  23.  
  24. ----
  25.  
  26. File: ./assets/xbreadcrumbs/onload.js
  27. The asset manage will consume all onload.js files for all assets and put them into a single $(function(){...}) statement/file.
  28. $('#crumbs').xbreadcrumbs({});
  29.  
  30. Result: File: ./assets/assets.compiled.js
  31. $(function(){
  32.     $('#crumbs').xbreadcrumbs({}); // xdebug
  33.     // all other assets onload.js
  34. });
  35.  
  36. ----
  37.  
  38. File: APPLICATION LAYOUT.PHTML
  39. <?php
  40. $this->_assetManager->load('xbreadcrumbs');
  41. ?>
RAW Paste Data
Top