Skip to content

Instantly share code, notes, and snippets.

View christianhanvey's full-sized avatar

Christian Hanvey christianhanvey

View GitHub Profile
@krismas
krismas / argv.php
Last active June 19, 2025 09:19
A small MODX snippet to extract POST, GET, SESSION & COOKIE values
<?php
/*
* A small MODX snippet to extract POST, GET, SESSION & COOKIE values - (c) 2012-2016 ackwa.fr
*
* @version : 1.0.4
* @see : https://gist.github.com/gists/2853625
* @name : argv.php
* @author : [email protected]
* @usage : [[!argv?key=`myparam`&default=`1`]] -> return the value
* [[!argv?key=`myparam`&default=`1`&toph=`1`]] -> set [[+argv.myparam]]
@silentworks
silentworks / gist:3608022
Created September 3, 2012 09:07
MODX Resource List with Type Ahead

Create a new Template Variable

Go to Input Options Tab

Change Input Type to:

  • Listbox (Multi-Select) - for multiple resource select
  • Listbox (Single-Select) - for Single resource select

In Input Option Values type: @SELECT `pagetitle` AS `name`,`id` FROM `[[+PREFIX]]site_content` WHERE `published` = 1 AND `deleted` = 0

@christianhanvey
christianhanvey / modx-upgrade.sh
Last active August 2, 2025 04:07
A shell script to help automate the upgrade of a MODX Revolution installation
#!/bin/bash
# modx-upgrade.sh
# ---------------
# A shell script to help automate the upgrade of a MODX Revolution installation
# This script is for traditional installations only - not advanced
#
# Instructions:
# 1. Update the config section with your own site specific details
# 2. Upload this file to your server, preferably outside of web root
@Flygenring
Flygenring / toResourceField.snippet.php
Last active March 28, 2022 21:47
MODX Snippet to get a field from a resource based on a supplied resource id, meant to be used as an output filter.
<?php
/**
* Gets a field from a resource based on a supplied resource id, meant to be used as an output filter.
*
* Based on a resource ID a field can be retrieved. This can be standard fields as 'pagetitle' or 'alias',
* but a few custom fields are also available; 'siblingNextId', 'childrenFirstId', and 'childrenCount'.
* Only resources that are not marked as 'deleted' or 'hidemenu', and that is marked as 'published' are returned.
* Examples:
* [[*id:toResourceField]] => returns the resource pagetitle
* [[*id:toResourceField=`alias`]] => returns the resource alias
@sindresorhus
sindresorhus / post-merge
Last active May 17, 2025 14:19
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"