Skip to content

Instantly share code, notes, and snippets.

@rtripault
rtripault / plugin.php
Created January 26, 2017 12:13
Plugin to add a "created by" field on a MODX Revolution resource form, listening on the "OnDocFormPrerender" event
<?php
/**
* Sample plugin to add a "created by" field on a resource form
*
* @var modX $modx
* @var array $scriptProperties
*
* @event OnDocFormPrerender
*/
@muhammadghazali
muhammadghazali / What is server_names_hash_bucket_size.md
Last active March 11, 2025 03:56
Nginx: What is server_names_hash_bucket_size?

Background

While I'm learning how to use Nginx, I was instructed to update the server_names_hash_bucket_size (/etc/nginx/nginx.conf) value from 32 to 64, but I don't understand why should I increase the value to 64.

References

References that have been read so far:

@chrisdempsey
chrisdempsey / Bezumkin equivalent plugin.php
Last active March 23, 2022 15:19
Automatically resizes images uploaded through the MODX File Manager if they exceed the dimensions specified in the config settings below and the file extension is included in the upload_images System Setting. Provides basic filename sanitization. Dependancies: Resizer Extra (http://modx.com/extras/package/resizer)
<?php
/**
* ResizeOnUpload Plugin
*
* Events: OnFileManagerUpload
* Author: Vasiliy Naumkin <[email protected]>
* Required: PhpThumbOf snippet for resizing images
*/
if ($modx->event->name != 'OnFileManagerUpload') {return;}
@bwente
bwente / form_date_selects.php
Created September 26, 2016 15:11
MODX FormIt date selections
<select name="dob-day" id="dob-day">
<option value="">Day</option>
<option value="">---</option>
<option value="01" [[!+fi.dob-day:FormItIsSelected=`01`]]>01</option>
<option value="02" [[!+fi.dob-day:FormItIsSelected=`02`]]>02</option>
<option value="03" [[!+fi.dob-day:FormItIsSelected=`03`]]>03</option>
<option value="04" [[!+fi.dob-day:FormItIsSelected=`04`]]>04</option>
<option value="05" [[!+fi.dob-day:FormItIsSelected=`05`]]>05</option>
<option value="06" [[!+fi.dob-day:FormItIsSelected=`06`]]>06</option>
<option value="07" [[!+fi.dob-day:FormItIsSelected=`07`]]>07</option>
@Rachind
Rachind / modx-clear-cache.php
Created September 13, 2016 21:33
MODX Clear Cache
<?php
// Dan Gibbs
// Clear MODx Revolution Cache (2.1 and later)
// Path to MODx Core Directory
define("MODX_CORE_PATH", "../core/");
define("MODX_CONFIG_KEY", "config");
// Include MODx main class
include(MODX_CORE_PATH . "model/modx/modx.class.php");
@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
@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 <[email protected]>
*
<?php
/**
* Based on @garryn Garry Nutting's amazingly fast sitemap generator:
* http://www.modx360.com/blog/2013/09/03/google-sitemap-thousands-of-resources/
*
* Modified by @sepiariver for multi-context support
* GPL, no warranties, etc.
*
*/
@Telling
Telling / f2bufwnginx.md
Created February 14, 2016 13:35
Setup fail2ban (v0.8.11) with ufw and nginx

Setup fail2ban (v0.8.11) with ufw and nginx on Ubuntu 14.04

Install fail2ban & ufw

If you haven't already, install fail2ban and ufw:

sudo apt-get install fail2ban ufw

Now make a copy of the fail2ban configuration, and name it jail.local:

@Drabush
Drabush / minifyHTML.php
Created February 6, 2016 13:00
HTML minifier plugin for MODX Revolution. Add to onWebPagePreRender event
<?php
//Минификация кода HTML. Включение плагина по событию onWebPagePreRender
$output = &$modx->resource->_output;
$output = preg_replace('|\s+|', ' ', $output);
$modx->resource->set('content', $output);