Skip to content

Instantly share code, notes, and snippets.

@sonicpunk
Created December 13, 2013 11:03
Show Gist options
  • Save sonicpunk/7942772 to your computer and use it in GitHub Desktop.
Save sonicpunk/7942772 to your computer and use it in GitHub Desktop.
Allows you to send a link to your javascript to the bottom of the page. Example call would be [[!sendJsBottom? &link=`/assets/js/scriptname.js`]]. With this snippet you can place it into a chunk that may contain elements for a component.
<?php
$link = $modx->getOption('link',$scriptProperties,'');
// For debugging:
$modx->log(modX::LOG_LEVEL_DEBUG
, '[sendJsBottom] called on page '. $modx->resource->id . ' with the following properties: '
.print_r($scriptProperties, true));
// Verify Inputs
if(isset($scriptProperties['link'])){
$modx->regClientScript($link);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment