Skip to content

Instantly share code, notes, and snippets.

@em-piguet
em-piguet / article2collections.sql
Created March 30, 2016 09:59
How to convert an MODX articles container to a MODX collections container...
# switch ArticlesContainer -> CollectionContainer
# the res. ID I want to migrate is 11
UPDATE `modx_site_content` SET `class_key` = replace(class_key, 'ArticlesContainer', 'CollectionContainer') WHERE id=11;
# switch class_key to go back to default document view for children
UPDATE `modx_site_content` SET `class_key` = replace(class_key, 'Article', 'modDocument') WHERE parent=11;
# Change template 49 -> 57
@em-piguet
em-piguet / site.conf
Last active September 14, 2015 14:04 — forked from markwillis82/site.conf
nginx config setup for modx + statcache
server {
root /path/to/site;
index index.php;
server_name somedomain.co.uk www.somedomain.co.uk;
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
@em-piguet
em-piguet / wp_changeLoginUrl.php
Last active May 3, 2022 22:06 — forked from tazeverywhere/wp_changeLoginUrl.php
WP - change login/admin URL
<?php
//////////////////////
// SECURE WP_ADMIN //
//////////////////////
// ---- 1. edit wp-config.php
/* tells wordpress what the new directory is, and updates the cookie path.
define( 'WP_ADMIN_DIR', 'manager' );
define( 'ADMIN_COOKIE_PATH', '/' );
*/
@em-piguet
em-piguet / findReplaceTV.php
Last active August 29, 2015 14:13
Batch Find and Replace a value in a MODX TV
<?php
/*
Name:
findReplaceTV
Description :
This snippet is useful if you want to batch replace a string in multiple resources at once.
@em-piguet
em-piguet / changeValue.php
Last active August 29, 2015 14:13
Batch resources value in MODX
/*
[[changeValue? &parent=`` &field=`` &value=`` ]]
*/
foreach ($modx->getIterator('modResource', array('parent' =>$parent)) as $res) {
$res->set($field,$value);
$res->save();
echo ($action.'=>'.$value.'! <br/>');
@em-piguet
em-piguet / changeTemplate.php
Last active August 29, 2015 14:13
changeTemplate (batch resources)
/*
[[changeTemplate &parent=`ID` &template=`ID`]]
*/
foreach ($modx->getIterator('modResource', array('parent' =>$parent)) as $res) {
$res->set('template',$template);
$res->save();
echo ('Mise à jour du template OK <br/>');
}
@em-piguet
em-piguet / 0_reuse_code.js
Created July 22, 2014 12:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@em-piguet
em-piguet / Replace SVG to inline SVG
Last active August 29, 2015 14:04
Replace all SVG images with inline SVG. Very useful if you need to use CSS on SVG
/*
* Replace all SVG images with inline SVG
*/
jQuery('img.svg').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
jQuery.get(imgURL, function(data) {
@em-piguet
em-piguet / sample.htaccess
Last active September 22, 2022 18:16
Add this in your .htaccess to get a better note on gtmetrix :)
# Make sure .htc files are served with the proper MIME type, which is critical
# for XP SP2. Un-comment if your host allows htaccess MIME type overrides.
AddType text/x-component .htc
# If your server is not already configured as such, the following directive
# should be uncommented in order to set PHP's register_globals option to OFF.
# This closes a major security hole that is abused by most XSS (cross-site