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 | |
/** | |
* getProps | |
* Snippet to access MODX Resource properties. | |
* @author @sepiariver | |
* | |
* @package ResourceProperties | |
* GPL+, no warranties express nor implied. | |
* | |
**/ |
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 cbGetFieldContent snippet to get the content of a particular field. | |
* | |
* For example, this can be useful if you need to get a bit of content | |
* in a getResources call | |
* | |
* Example usage: | |
* | |
* [[cbGetFieldContent? |
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 | |
$success = false; | |
if (!empty($value)) { | |
$re = "/^((((\+[\d\-.]{1,5})?[ \-.]?\d{3})|(\+[\d\-.]{1,5})?[ \-.]?\((\d{3}\)))?[ \-.]?\d{3}[ \-.]?\d{4}\s?(e?x?t?\.?\s?\d{1,7})?)?$/i"; | |
if (preg_match($re, $value) === 1) $success = true; | |
} | |
if (!$success) { | |
$validator->addError($key, 'Please enter a valid phone number.'); | |
return false; | |
} else { |
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 | |
/** | |
* Steps to implement | |
* 1. Set HTML content-type default suffix to '/' | |
* 2. Ensure Resources have isFolder = 1 as default | |
* 3. If you still have issues with Resources being routed to the URI without a trailing slash, | |
* create this Plugin and enable it 'OnWebPageInit'. | |
**/ | |
if ($modx->event->name !== 'OnWebPageInit') return; | |
if (substr($_SERVER['REQUEST_URI'], -1) !== '/') $modx->sendRedirect($_SERVER['REQUEST_URI'] . '/', 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
<?php | |
/** | |
* getter function for resource properties. sets placeholders with all values. | |
* optionally allows direct return of one element within the namespaced properties sub-array | |
* @author @sepiariver | |
* | |
**/ | |
// OPTIONS | |
$id = (int) $modx->getOption('id', $scriptProperties, 0); |
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 | |
/** | |
* | |
* @author @sepiariver | |
* | |
**/ | |
if ($modx->context->get('key') !== 'mgr' || $modx->event->name !== 'OnDocFormSave') return; | |
if (!($resource instanceof modResource)) { | |
$modx->log(modX::LOG_LEVEL_ERROR, 'setResourceProps Plugin did not have access to a valid resource object on line: ' . __LINE__); | |
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 | |
/* | |
* SaveProcessedContent | |
* @author @theboxer | |
* @comments @sepiariver | |
* | |
* GPL, no warranties, etc. | |
* | |
* USAGE: | |
* Enable 'OnDocFormSave' event in Plugin properties, and supply a valid "tvName" value. |
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 | |
/* | |
* @author @sepiariver | |
* | |
* GPL license, no warranties, no liability, etc. | |
* | |
* USAGE EXAMPLE: | |
* [[rootResource? &toPlaceholder=`root_resource`]] | |
* //followed by something like |
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 | |
/* | |
* @author @sepiariver | |
* | |
* GPL, no warranties, no liability, etc. | |
* | |
* USAGE EXAMPLE: | |
* [[!FormIt? &hooks=`iContactPost`]] | |
* | |
* NOTE: using iContact's API would be a more robust approach |
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 | |
/* | |
* MODX Plugin to sandbox Users by User Group, to a specific Resource container. | |
* | |
* @author @sepiariver | |
* GPL, no warranties, no liability, etc. | |
* | |
* Create a Plugin with the code from this gist. Enable the 'OnDocFormPrerender' event | |
* in the 'System Events' tab of the Plugin. Create a namespace, e.g. 'sandbox', and | |
* the following system settings with that namespace: 'sandbox.allow_create', |