Skip to content

Instantly share code, notes, and snippets.

@christianseel
christianseel / Remove SeoTab Branding
Created February 20, 2014 16:55
Add this php code as a plugin to your MODX manager and check the 'OnDocFormPrerender' system event. This removes the branding from the SEOTab extra by Sterc.
<?php
$modx->regClientStartupHTMLBlock('<style>
#modx-resource-tabs__seo-tab {
border-color: #658F1A;
background: url(/manager/templates/default/images/modx-theme/tabs/tab-bg.svg) #658F1A;
background: -moz-linear-gradient(center bottom,#658F1A 0%,#8BAF4C 100%) repeat scroll 0 0 transparent;
background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#8BAF4C),color-stop(100%,#658F1A));
background: -webkit-linear-gradient(center bottom,#658F1A 0%,#8BAF4C 100%);
background: -o-linear-gradient(center bottom,#658F1A 0%,#8BAF4C 100%);
background: -ms-linear-gradient(center bottom,#658F1A 0%,#8BAF4C 100%);
@christianseel
christianseel / hinweise.js
Created April 10, 2014 20:43
Dieser JS Code fügt in die rechte Spalte einer Resource beliebigen HTML Code ein (z.B. Hinweise). Sollte per Plugin OnDocFormPreRender eingefügt werden.
var content = '';
content += '<h3>Hinweise</h3>';
content += '<p>Hinweistext</p>';
content += '<style>.hdkInfo-panel p {margin-bottom: 10px; line-height:1.6;} .hdkInfo-panel h4 {margin-top: 15px; margin-bottom: 5px;}</style>';
var hdkInfo = function(config) {
@christianseel
christianseel / moregallery img to TV
Last active August 29, 2015 14:01
Add this as a plugin (OnDocFormSave). Saves the first MoreGallery image into a TV (could be a hidden one) for quicker access.
// Get the images
$corePath = $modx->getOption('moregallery.core_path', null, $modx->getOption('core_path') . 'components/moregallery/');
$moreGallery = $modx->getService('moregallery', 'moreGallery', $corePath . 'model/moregallery/');
$c = $modx->newQuery('mgImage');
$c->where(array(
'resource' => $resource->get('id'),
));
$c->sortby('sortorder', 'ASC');
$c->limit('1');
@christianseel
christianseel / .htaccess
Created July 6, 2014 12:19 — forked from splittingred/.htaccess
MODX 2.3 REST example
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ rest/index.php?_rest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ rest/index.php [QSA,NC,L]
</IfModule>
@christianseel
christianseel / babel.css
Created July 30, 2014 07:13
Updated CSS for Babel in MODX 2.3.x – quick&dirty
/**
* Babel CSS file
*
* @author Jakob Class <jakob.class@class-zec.de>
*
* @package babel
*/
#babel-box{
background: rgba(230,230,230,.7);
margin: 0px 0 0;
@christianseel
christianseel / gist:9ef49c1a2f225c337909
Created October 5, 2014 16:45
Replace ContentBlocks values with new values
<?
$c = $modx->newQuery('modResource');
$resources = $modx->getCollection('modResource', $c);
foreach ($resources as $res) {
$properties = $res->getProperties('contentblocks');
if (empty($properties)) continue;
if (empty($properties['content'])) continue;
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@christianseel
christianseel / XRouting 1.3.1
Created January 20, 2015 14:43
XRouting 1.3.1 (with debug info: add ?xrdebug=1 to your URL)
<?php
switch ($modx->event->name) {
// "refresh cache" part
case 'OnContextSave':
case 'OnContextRemove':
case 'OnSiteRefresh':
$contexts = array();
$cacheKey = 'xrouting_contextmap';
@christianseel
christianseel / gist:5013671
Created February 22, 2013 14:12
GoogleSitemap Snippet: use latest publication date as date field for articles container
if ($child instanceof ArticlesContainer) {
$date = $this->modx->runSnippet('getResources',array(
'showHidden' => '1',
'parents' => $id,
'depth' => '1',
'limit' => '1',
'published' => '1',
'sortby' => '{"publishedon":"DESC"}',
'tpl' => 'getResources.publishedon'
));
@christianseel
christianseel / .htaccess
Last active December 27, 2015 20:19
MODX Revolution default .htaccess for All-Inkl.com
# ----------------------------------------------------------------------
# PHP Settings
# ----------------------------------------------------------------------
# php cgi 5.4.x
AddHandler php54-cgi .php
# set default timezone
php_value date.timezone "Europe/Berlin"