Skip to content

Instantly share code, notes, and snippets.

@christianseel
Last active February 2, 2016 12:54
Show Gist options
  • Save christianseel/401500aa8fedb9d64980 to your computer and use it in GitHub Desktop.
Save christianseel/401500aa8fedb9d64980 to your computer and use it in GitHub Desktop.
Usage: [[!regClient? &input=`markup or script here` &function=`htmlToBottom`]]
<?php
$options = isset($options) ? $options : 'htmlToBottom';
$function = $modx->getOption('function', $scriptProperties, $options);
$plaintext = (strstr($input, PHP_EOL)) ? true : false;
switch ($function) {
case 'cssToHead':
$modx->regClientCSS($input);
break;
case 'htmlToHead':
$modx->regClientStartupHTMLBlock($input);
break;
case 'htmlToBottom':
$modx->regClientHTMLBlock($input);
break;
case 'jsToHead':
$modx->regClientStartupScript($input,$plaintext);
break;
case 'jsToBottom':
$modx->regClientScript($input,$plaintext);
break;
}
return '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment