Skip to content

Instantly share code, notes, and snippets.

View goldsky's full-sized avatar

rico goldsky

View GitHub Profile
@goldsky
goldsky / login.redirect.usergroups.plugin.php
Created May 21, 2012 10:19
MODX's plugin to redirect specified usergroups after logged in using the Login snippet
<?php
if ($modx->event->name !== 'OnWebLogin')
return;
$usergroups = $user->getUserGroupNames();
if(empty($usergroups))
return;
switch (TRUE) {
@goldsky
goldsky / getTVText.php
Last active June 23, 2023 12:53
Dynamically Render MODX's Template Variable on front-end to get Text and Value
<?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>
*
@goldsky
goldsky / transformKeys.php
Created August 16, 2012 18:36
Convert under_score type array's keys to camelCase type array's keys and likewise
<?php
/**
* Convert under_score type array's keys to camelCase type array's keys
* @param array $array array to convert
* @param array $arrayHolder parent array holder for recursive array
* @return array camelCase array
*/
public function camelCaseKeys($array, $arrayHolder = array()) {
$camelCaseArray = !empty($arrayHolder) ? $arrayHolder : array();
@goldsky
goldsky / sticky-footer.css
Last active October 27, 2021 02:50
Sticky footer using CSS's display: table, inspired by: http://pixelsvsbytes.com/blog/2012/02/this-css-layout-grid-is-no-holy-grail/
@goldsky
goldsky / connector.php
Last active November 25, 2020 20:30
Ajax's connector file using MODX's main index.php
<?php
/**
* Ajax Connector
*
* @package mypackage
*/
$validActions = array(
'web/data/delete',
'web/data/edit'
@goldsky
goldsky / validate.popover.js
Created November 6, 2012 04:40
A javascript function using jQuery's validation and twitter bootstrap's popover
function validateForm(formId, erPlacement, validRules) {
erPlacement = erPlacement || 'bottom';
validRules = validRules || {};
/* Validation message with the twitter's popover */
/* http://d.hatena.ne.jp/hipsrinoky/20120329/1333035926 */
var eClass = 'error'; // for bootstrap
var sClass = 'success'; // for bootstrap
var wClass = 'warning'; // for bootstrap (not in used)
$(formId).validate({
@goldsky
goldsky / sticky-footer-2.css
Last active September 14, 2018 11:46
Sticky footer using CSS's display: table, inspired by: http://pixelsvsbytes.com/blog/2012/02/this-css-layout-grid-is-no-holy-grail/
@goldsky
goldsky / refresh-static-elements.php
Last active June 12, 2018 03:36
Refresh all static elements entirely
<?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 / jquery.stoc.js
Created January 28, 2012 12:16
jQuery Plugin: Table of Contents with Smooth Scrolling
/**
* jQuery Plugin: Table of Contents with Smooth Scrolling
* @link http://www.1stwebdesigner.com/css/jquery-plugin-smooth-scrolling/
* @author Rochester Oliveira
*/
(function($){
$.fn.stoc = function(options) {
//Our default options
var defaults = {
@goldsky
goldsky / getGalleryCoverByTV.php
Last active April 28, 2017 09:23
Get gallery's cover from Template Variable
<?php
/**
* getGalleryCoverByTV snippet
* Get gallery's cover from Template Variable
*
* @author goldsky <goldsky@virtudraft.com>
* @license GPLv3
*/
$toPlaceholder = $modx->getOption('toPlaceholder', $scriptProperties);