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 | |
/** | |
* Use the cbGetLayoutSetting snippet to get a setting from a particular layout. | |
* @author YJ Tso @sepiariver <[email protected]> | |
* @param (id) &resource allows checking for fields on other resources. | |
* @param (bool) &showDebug return debugging info as JSON. | |
* @param (string) &toPlaceholder set a placeholder with this string as key, instead of returning. | |
* @param required (int) &layout - ID of ContentBlocks layout from which to fetch the setting. | |
* @param required (string) &setting - key of layout setting to return. | |
* |
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 | |
/** | |
* getJsonProperty | |
* | |
* Example usage: | |
* [[getJsonProperty? | |
* &tpl=`myChunkTpl` | |
* &key=`0.rows.0.repeater.rows` | |
* &json=`[[cbGetFieldContent? &field=`28` &returnAsJSON=`1`]]` | |
* ]] |
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 | |
if (empty($input) || !is_numeric($input)) return $input; | |
$opts = array_filter(array_map('trim', explode(',', $options))); | |
$args = array(); | |
$args['decimals'] = (isset($opts[0])) ? intval($opts[0]) : 2; | |
$args['dec_point'] = (isset($opts[1])) ? (string) $opts[1] : '.'; | |
$args['thousands_sep'] = (isset($opts[2])) ? (string) $opts[2] : ','; | |
return number_format(floatval($input), $args['decimals'], $args['dec_point'], $args['thousands_sep']); |
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 | |
/** | |
* imageplusvalue is a Snippet/Output Modifier to parse | |
* the ImagePlus stored JSON and return values or thumbs. | |
* | |
* @author YJ Tso <[email protected]> | |
* | |
* Example usage: | |
* <img src="[[*image:imageplusvalue=`croppedImg:w=840&zc=1`]]" alt="[[*image:imageplusvalue=`altTag`]]"> | |
* |
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
// Array.diff() | |
if (typeof Array.prototype.diff === 'undefined') { | |
Array.prototype.diff = function() { | |
var result = arguments[0]; | |
delete arguments[0]; | |
if (!(result instanceof Array)) { | |
throw new TypeError('1st argument passed to Array.diff was not an array'); |
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
# statcache bits | |
set $cache_prefix 'statcache'; | |
if ($http_user_agent = 'MODX RegenCache') { | |
set $cache_prefix 'no cache'; | |
} | |
# CORS for CDN pull zone and expires directives | |
location ~* \.(?:ico|css|js|jpe?g|png|gif|svg|pdf|mov|mp4|mp3|woff|woff2|ttf|ttc|otf|eot|font.css)$ { | |
expires 7d; | |
add_header Access-Control-Allow-Origin "*"; | |
add_header Pragma public; |
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 | |
// Only run this via SSH | |
if (PHP_SAPI !== 'cli') return; | |
// Sometimes helpful if processing lots of Resources | |
ini_set('memory_limit', '2048M'); | |
// Init @modx | |
@include(dirname(__FILE__) . '/config.core.php'); | |
if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(__FILE__) . '/core/'); | |
include_once (MODX_CORE_PATH . "model/modx/modx.class.php"); | |
$modx= new modX(); |
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 | |
// Only ssh users can execute | |
if (PHP_SAPI !== 'cli') return; | |
// Comes in handy sometimes | |
ini_set('memory_limit', '2048M'); | |
// Instantiate MODX | |
@include(dirname(__FILE__) . '/config.core.php'); | |
if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(__FILE__) . '/core/'); | |
include_once (MODX_CORE_PATH . "model/modx/modx.class.php"); | |
$modx= new modX(); |
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 | |
// Only executable via SSH | |
if (PHP_SAPI !== 'cli') exit(); | |
// Instantiate MODX | |
@include(dirname(__FILE__) . '/config.core.php'); | |
if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(__FILE__) . '/core/'); | |
include_once (MODX_CORE_PATH . "model/modx/modx.class.php"); | |
$modx= new modX(); | |
$modx->initialize('web'); |
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 | |
// Only run via SSH | |
if (PHP_SAPI !== 'cli') exit(); | |
// Instantiate MODX | |
@include(dirname(__FILE__) . '/config.core.php'); | |
if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(__FILE__) . '/core/'); | |
include_once (MODX_CORE_PATH . "model/modx/modx.class.php"); | |
$modx= new modX(); | |
$modx->initialize('web'); |