Skip to content

Instantly share code, notes, and snippets.

@pepebe
pepebe / gist:3957784
Created October 26, 2012 09:12
MODx - All-purpose-snippet
<?php
/* runFn Snippet
* by info@pepebe.de
*
* Pass the snippet a php function name and pipe delimited list of parameters.
*
* Example: Format a large number with number_format()
* See: www.php.net/manual/en/function.number-format.php
*
* [[!runFn? &fn=`number_format` &args=`123456789||2||,||.`]]
@gadamiak
gadamiak / LangRouter.php
Created October 1, 2012 16:31
Language context router for use with Babel extra for MODX Revolution
<?php
/* LangRouter
* ==========
*
* This plugin is meant to be used with Babel extra for MODX Revolution. It
* takes care of switching contexts, which hold translations, depending on URL
* requested by client. LangRouter works with so called subfolder based setup,
* in which many languages are served under a single domain but are
* differentiated by a virtual subfolder indicating the language, eg.
* mydomain.com/pl/.
@FuzzicalLogic
FuzzicalLogic / setParentTemplate.snippet.php
Created September 13, 2012 06:18
MODx Revolution: Allows you to "nest" a MODx Revolution Template within another MODx Revolution Template. Requires the use of a Template Switcher plugin
<?php
// Requires an Template ID
if (empty($id))
return '';
else
{//Get the Template
$parent = $modx->getObject('modTemplate', $id);
// Must be a valid Template ID
if (empty($parent))
return '';
@ovomatik
ovomatik / argv.php
Created August 31, 2012 21:42 — forked from krismas/argv.php
A small MODX snippet to extract POST, GET, SESSION & COOKIE values - (c) 2012 ackwa.fr
<?php
/*
* A small MODX snippet to extract POST, GET, SESSION & COOKIE values - (c) 2012 ackwa.fr
*
* @version : 1.0.1
* @see : https://gist.github.com/gists/2853625
*
* @usage : [[!argv?key=`myparam`&default=`1`]] -> return the value
* [[!argv?key=`myparam`&default=`1`&toph=`1`]] -> set [[+argv.myparam]]
* [[!argv?key=`myparam`&from=`GP`]] -> return the value from GET or POST
@krismas
krismas / now.php
Created July 24, 2012 12:51
A small MODX snippet to time other snippets
<?php
/*
* A small MODX snippet to time other snippets - (c) 2012 ackwa.fr
*
* @see : https://gist.github.com/gists/3169775
* @name : now.php
* @author : g.noel@ackwa.fr
* @usage : [[!now]] -> First call
* [[!now?seed=`1`]] -> subsequent calls
*
@brianblakely
brianblakely / rem-calibrate.css
Created July 13, 2012 18:55
Simulate vw with rems
/* Android stock browser won't let you set font-size smaller than 8px unless you apply this. */
:root {
-webkit-text-size-adjust: none;
-moz-text-size-adjust: none;
-ms-text-size-adjust: none;
-o-text-size-adjust: none;
text-size-adjust: none;
}
@Fordi
Fordi / checkbox.css
Created June 12, 2012 16:44
Cross-browser checkbox styling with graceful fallback (now with less!)
/**
Usage (the label is required)
<input id="uid" type="checkbox" ... /><label for="uid">Label</label>
Produces styled checkboxes in IE9+, current Firefox and Chrome
Demo here: http://jsfiddle.net/7Fggq/
@author Bryan Elliott <ook@codemonkeybryan.com>
*/
@christianhanvey
christianhanvey / modx-snippets.php
Last active June 14, 2023 13:02
Useful snippets for MODX Revo
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@chucktrukk
chucktrukk / modx.api.connector.php
Created April 19, 2012 19:38
Load and instantiate MODxAPi from a directory
<?php
if( !isset($modx) ) {
/*Test the realpath by just starting with /../ and keep adding till you get where you're going*/
$modx_base_path = realpath(dirname(__FILE__) . '/../../../../../');
define('MODX_BASE_PATH', $modx_base_path.'/' );
$old_dir = getcwd();
chdir(MODX_BASE_PATH);
require MODX_BASE_PATH . 'manager/includes/config.inc.php';
@splittingred
splittingred / .htaccess
Created April 9, 2012 21:48
Example of how to use new REST server class in MODX 2.3+
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ rest/index.php?_rest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ rest/index.php [QSA,NC,L]
</IfModule>