Skip to content

Instantly share code, notes, and snippets.

View Jako's full-sized avatar

Thomas Jakobi Jako

View GitHub Profile
@Jako
Jako / gist:8ba13f097b36e94fe315f505d3003d8b
Created August 30, 2016 06:48
Formit RedirectByValue Hook
<?php
/**
* RedirectByValue
*
* Copyright 2016 by Thomas Jakobi <thomas.jakobi@partout.info>
*
* Description:
* This FormIt Hook redirects to different targets on base of the
* formItRedirectByValue property. The property has to contain a json encoded
* object of fieldnames, values, redirects and redirect parameters. Only a
@Jako
Jako / resolve.access_permissions.php
Created November 20, 2016 12:56
Access permissions resolver for MODX packages
<?php
/**
* Resolve access permissions
*
* @package sample
* @subpackage build
*
* @var mixed $object
* @var array $options
*/
@Jako
Jako / Revolution-Integrators-Guide.md
Last active January 26, 2017 13:02
Revolution Integrators Guide

Few rules

  • Don't merge own PRs
  • Don't do direct changes (submit a PR instead)

GitHub repository setup

  • Clone your fork
  • Add modxcms/revolution as a remote (git remote add upstream git@github.com:modxcms/revolution.git)
  • Update .git/config and add fetch = +refs/pull/*/head:refs/remotes/upstream/pr/* in section [remote "upstream"]
@Jako
Jako / gist:c9ea82324c62c90c15ade95254ac57e1
Created November 16, 2016 14:31
Recursive download with curl and open_basedir
/**
* Load data from URL with curl
*
* @param $url
* @return mixed
*/
public function loadData($url)
{
$curloptHeader = false;
@Jako
Jako / code_patterns.md
Last active March 15, 2021 08:54
Code patterns for Extras compatibility in MODX3 and MODX2

Code patterns for Extras compatibility in MODX3 and MODX2

Use a fqn prefix for modTransport classes:

$modx->getTableName('modTransportPackage')

to

@Jako
Jako / cbGetLayoutSettings.snippet.php
Last active August 20, 2021 08:46
Get a templated list of ContentBlocks layout settings
<?php
/**
* Use the cbGetLayoutSettings snippet to get a templated list of settings from a particular layout.
* Based on cbGetLayoutSetting snippet https://gist.github.com/sepiariver/302ab3cc7bd47233f0136f4379de89cf
*
* @param (id) &resource allows checking for fields on other resources.
* @param (bool) &showDebug return debugging info as JSON.
* @param (string) &toPlaceholder set a placeholder with this string as key, instead of returning.
* @param (int) &layout - (required) ID of ContentBlocks layout from which to fetch the settings.
* @param (string) &tpl - name of chunk for templating the settings of one layout.
@Jako
Jako / gist:0679e1b23cb8f5c5494c6826eba0f6a9
Created October 18, 2019 17:41
MODX FormIt Email Selector
<?php
$selectField = $modx->getOption('emailSelectField', $scriptProperties, 'department');
$selectTo = $modx->getOption('emailSelectTo', $scriptProperties, '');
$selectTo = ($selectTo) ? explode(',', $selectTo) : array();
if ($selectField && $selectTo) {
$selected = intval($hook->getValue($selectField)) - 1;
if ($selected && isset($selectTo[$selected])) {
$hook->formit->config['emailTo'] = $selectTo[$selected];
}