Created
March 20, 2013 12:13
-
-
Save silentworks/5204211 to your computer and use it in GitHub Desktop.
Including CSS and JS in any page to head and before body tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * Register CSS and JS to load in head of website | |
| */ | |
| $link = $modx->getOption('link', $scriptProperties, ''); | |
| if (empty($link)) { | |
| return false; | |
| } | |
| $links = explode(',', preg_replace('/\s+/', '', $link)); | |
| foreach ($links as $lnk) { | |
| list($type, $lnk) = explode('||', $lnk); | |
| if ($type === 'css') { | |
| $modx->regClientCSS($lnk); | |
| } | |
| if ($type === 'js') { | |
| $modx->regClientScript($lnk); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| How to use | |
| [[!cssJSRegister?link=` | |
| css||/assets/css/flexslider.css, | |
| js||/assets/js/jquery.flexslider-min.js, | |
| js||/assets/js/global.js | |
| `]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment