Skip to content

Instantly share code, notes, and snippets.

@matdave
matdave / FormIt.example.html
Last active February 26, 2018 16:09
MODX Invisible Recaptcha Formit Validator
[[!FormIt?
&submitVar=`gcaptchahdn`
&customValidators=`invisibleRecaptcha`
&validate=`
g-recaptcha-response:invisibleRecaptcha`
]]
<form method="post" action="[[~[[*id]]]]" id="contact">
<button class="btn g-recaptcha" data-sitekey="[[++gcaptcha.site_key]]" data-callback="onSubmit">Submit</button>
</form>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
@matdave
matdave / resourceToTag.plugin.php
Last active February 28, 2018 20:34
resourceToTag
<?php
//Plugin to autocreate tags
switch ($modx->event->name) {
case 'OnDocFormSave':
if(!empty($resource)){
$temp = $resource->get('template');
//templates to autotag
if($temp == 21 || $temp == 22){
$pagetitle = null;
.brandbkg1::before {
content: "";
position: absolute;
width: 150%;
height: 2000px;
top: -875px;
left: -25%;
z-index: -1;
background: url('../gfx/mandala.png');
background-size: cover;
@matdave
matdave / FontAwesomeIcon.chunk.tpl
Created April 6, 2018 21:07
MODX Font Awesome Selector TV
[[+icon_class:replace=`fa-==`]] <i class="[[+icon_class:replace=`fa-==icon-`]] icon icon-large"></i>
@matdave
matdave / mailtofix.hook.php
Created June 8, 2018 18:07
MODX FormIt Multi-Email Fix (for dynamic emails)
<?php
$fields = $hook->getValues();
$emailTo = $hook->formit->config['emailTo'];
if(strpos($emailTo,'[[+') !== false){
$emailVar = str_replace('[[+','',$emailTo);
$emailVar = str_replace(']]','',$emailVar);
$hook->formit->config['emailTo'] = $fields[$emailVar];
}
return true;
@matdave
matdave / element.chunk.html
Last active July 10, 2018 01:43
Build Anchor Menu in Fred.
<section id="{{ anchortext|lower|replace({' ': ''}) }}" >
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto text-center">
<h2 class="section-heading" contenteditable="true" data-fred-name="head">Header</h2>
<hr class="light my-4">
<div class="text-faded mb-4 text-left" contenteditable="true" data-fred-name="text" data-fred-rte="true" data-fred-rte-config="text">
<p>Some Text</p>
</div>
</div>
@matdave
matdave / fredMigrate
Created August 2, 2018 15:34
Fred Migration for GPM (Run once)
<?php
$corePath = $modx->getOption('fred.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/fred/');
/** @var Fred $fred */
$fred = $modx->getService(
'fred',
'Fred',
$corePath . 'model/fred/',
array(
'core_path' => $corePath
)
@matdave
matdave / changeprefix.sql
Last active August 3, 2018 14:31
Change Prefix to MODX in MySQL
/* Drop MODX */
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' )
AS statement FROM information_schema.TABLES WHERE table_schema = 'instance_cXXXX_modx' AND table_name LIKE 'modx_%';
/* Change incorrect prefix */
SELECT CONCAT( 'RENAME TABLE ', TABLE_NAME, ' TO ', replace(TABLE_NAME, 'wrong_', 'modx_'), ';')
AS statement FROM information_schema.TABLES WHERE table_schema = 'instance_cXXXX_modx' AND table_name LIKE 'wrong_%';
@matdave
matdave / fixjson.php
Last active September 27, 2018 18:48
Fix Media Sources
<?php
function fixJSON($array, $mediaSources) {
$fix = array();
foreach( $array as $key => $value) {
if (is_array($value)) {
$fix[$key] = fixJSON($value);
} else{
if(in_array($key, array('mediaSource','imageMediaSource')){
if(!empty($mediaSources[$value])){
$value = $mediaSources[$value];
@matdave
matdave / keybase.md
Created October 1, 2018 10:44
keybase.md

Keybase proof

I hereby claim:

  • I am matdave on github.
  • I am matjones (https://keybase.io/matjones) on keybase.
  • I have a public key whose fingerprint is 844B 38BB 2C5A 974B 5667 F125 3AED 15C3 A370 EE19

To claim this, I am signing this object: