Skip to content

Instantly share code, notes, and snippets.

Avatar

rico goldsky

View GitHub Profile
@goldsky
goldsky / refresh-static-elements.php
Last active Jun 12, 2018
Refresh all static elements entirely
View refresh-static-elements.php
<?php
/**
* Refresh all static elements entirely
* MODX Revolution
* @author goldsky@virtudraft.com
*/
define('MODX_API_MODE', true);
/**
* CHANGE this reference to the main index.php!
*/
@goldsky
goldsky / getGalleryCoverByTV.php
Last active Apr 28, 2017
Get gallery's cover from Template Variable
View getGalleryCoverByTV.php
<?php
/**
* getGalleryCoverByTV snippet
* Get gallery's cover from Template Variable
*
* @author goldsky <goldsky@virtudraft.com>
* @license GPLv3
*/
$toPlaceholder = $modx->getOption('toPlaceholder', $scriptProperties);
@goldsky
goldsky / getTVText.php
Last active Dec 11, 2017
Dynamically Render MODX's Template Variable on front-end to get Text and Value
View getTVText.php
<?php
/**
* getTVText snippet
*
* Dynamically Render Template Variable on front-end to get not only the value,
* but also its input's "text"
*
* @author goldsky <goldsky@virtudraft.com>
*
View xrouting.plugin.php
<?php
switch ($modx->event->name) {
// "refresh cache" part
case 'OnContextSave':
case 'OnContextRemove':
case 'OnSiteRefresh':
$contexts = array();
$cacheKey = 'xrouting_contextmap';
@goldsky
goldsky / .htaccess
Created Feb 15, 2016
htaccess example for Babel
View .htaccess
# MODX supports Friendly URLs via this .htaccess file. You must serve web
# pages via Apache with mod_rewrite to use this functionality, and you must
# change the file name from ht.access to .htaccess.
#
# Make sure RewriteBase points to the directory where you installed MODX.
# E.g., "/modx" if your installation is in a "modx" subdirectory.
#
# You may choose to make your URLs non-case-sensitive by adding a NC directive
# to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
@goldsky
goldsky / includeFile.snippet.php
Last active Jul 20, 2016
includeFile snippet is to include any file in MODX's page, either in resource, template, or chunk
View includeFile.snippet.php
<?php
/**
* includeFile snippet is to include any file in MODX's page, either in resource, template, or chunk
*
* @author goldsky <goldsky@virtudraft.com>
* @copyright Copyright (c) 2015, goldsky
* @example [[!includeFile? &file=`[[++core_path]]statics/chunks/mychunk.chunk.tpl`]]
* [[!includeFile? &file=`[[++core_path]]statics/snippets/mysnippet.snippet.php`]]
*
@goldsky
goldsky / step2DynamicFieldsEmail.wrapper.html
Created Jun 21, 2014
Wrapper template for fiDynamicFieldsEmail snippet to revert dynamic field in step-2
View step2DynamicFieldsEmail.wrapper.html
<tr>
<td>Positions</td>
<td>:</td>
<td><ul>[[+dynfield.items]]</ul></td>
</tr>
@goldsky
goldsky / step2DynamicFieldsEmail.item.html
Created Jun 21, 2014
Row template for fiDynamicFieldsEmail snippet to revert dynamic field in step-2
View step2DynamicFieldsEmail.item.html
<li>[[+dynfield.position]]</li>
@goldsky
goldsky / step1DynamicFieldsEmail.wrapper.html
Created Jun 21, 2014
Wrapper template for fiDynamicFieldsEmail snippet to revert dynamic field in step-1
View step1DynamicFieldsEmail.wrapper.html
<tr>
<td>Telephones</td>
<td>:</td>
<td><ul>[[+dynfield.items]]</ul></td>
</tr>
@goldsky
goldsky / step1DynamicFieldsEmail.item.html
Created Jun 21, 2014
Row template for fiDynamicFieldsEmail snippet to revert dynamic field in step-1
View step1DynamicFieldsEmail.item.html
<li>[[+dynfield.telephone]]</li>