Skip to content

Instantly share code, notes, and snippets.

View NatemcM's full-sized avatar

Nathanael McMillan NatemcM

View GitHub Profile
@NatemcM
NatemcM / modx-snippets.php
Created January 13, 2021 10:52 — forked from christianhanvey/modx-snippets.php
Useful snippets for MODX Revo
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@NatemcM
NatemcM / createImg.pthumnb.modx.php
Last active January 15, 2021 00:22
A snippet that creates a <picture></picture> element with webp & jpg sources using pThumb with different media sizes depending on layout for bootstrap
<?php
$img_src = $modx->getOption('src', $scriptProperties);
$img_alt = $modx->getOption('alt', $scriptProperties);
$img_width = $modx->getOption('width', $scriptProperties,640);
$is_lazy = $modx->getOption('lazy', $scriptProperties, false);
$img_class = $modx->getOption('class', $scriptProperties, 'img-fluid');
$colums = $modx->getOption('cols', $scriptProperties, '{"xs":12,"sm":12,"md":8,"lg":6,"xl":6}');
$img_type = $modx->getOption('type', $scriptProperties, 'jpg');
$dataAttr = '';
@NatemcM
NatemcM / getFormitForm.php
Last active June 27, 2023 14:57
Formit csv export
<?php
# Edited GIST based on: https://community.modx.com/t/better-way-to-access-formit-form-data/6828
/**
* Snippet to get formit forms by name
* usage:
* [[!getFormitForm? &name=`Name of form`]]
*/
/**
@NatemcM
NatemcM / Nowdate MODX
Created October 18, 2019 02:17
MODX Now date snippet
[[!+nowdate:default=`now`:strtotime:date=`%Y`]]
@NatemcM
NatemcM / NGINX Config
Last active August 6, 2020 07:25
MODX Cloud NGINX Config
# Redirect to www and force HTTPS
#add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
}
# www.mydomain.com -> mydomain.com
# if ($host = "www.mydomain.com") {
# return 301 $scheme://mydomain.com$request_uri;
@NatemcM
NatemcM / Fred RTE Config - Bootstrap
Last active April 17, 2020 15:40
Light weight TinyMCE for Fred using Bootstrap styles
{
"theme": "inlite",
"inline": true,
"plugins": "modxlink image imagetools media lists hr code visualblocks table",
"insert_toolbar": "image media quicktable modxlink hr",
"selection_toolbar": "styleselect fontsizeselect | alignleft aligncenter alignright bullist numlist | quickimage media table modxlink | undo redo removeformat | visualblocks code",
"image_advtab": true,
"imagetools_toolbar": "editimage imageoptions | alignleft aligncenter alignright | rotateleft rotateright | flipv fliph | removeformat code",
"image_class_list": [
{
@NatemcM
NatemcM / sessionmanager.class.php
Created April 23, 2018 07:30 — forked from chrisdempsey/sessionmanager.class.php
SessionManager: A script that can be used for easy control over your session variables
<?php
/**
* SessionManager
* A script that can be used for easy control over your session variables.
* Put this script in your core/components/ folder, inside a sessionman/ subdirectory.
*
* Load this one in your snippets/plugins like;
*
* $sessman = $modx->getService('session','SessionManager', $modx->getOption('sessman.core_path',null,$modx->getOption('core_path').'components/sessionman/'), $scriptProperties);
* if(!($sessman instanceof SessionManager)) { $modx->log(modX::LOG_LEVEL_ERROR, 'Session manager could not be loaded..'); return ''; }