Skip to content

Instantly share code, notes, and snippets.

@sebastian-marinescu
sebastian-marinescu / cbContentEditor.php
Created October 28, 2018 14:13 — forked from jonleverrier/cbContentEditor.php
This MODX plugin hides certain Content Blocks buttons from a specific MODX user group. It also disables the drag and drop functionality, so that you can provide some users with a more locked down version of Content Blocks.
<?php
/**
* Content Blocks cbContentEditor Plugin
*
* This plugin hides certain CB buttons from certain MODX user groups
* and disables the drag and drop functionality, so that you can provide
* some clients with a more locked down version of CB.
*
* I would suggest setting up CB templates and defaults in the CB component manager,
* so that predefined layouts are loaded automatically when a new resource is created.
@jonleverrier
jonleverrier / getFormSteps.snippet.php
Last active December 12, 2018 17:18
getFormSteps for the MODX Formalicious form builder by Sterc. This utility snippet displays all the step titles for a given form ID.
<?php
/**
* getFromSteps v.1.0
* An unoffical utility snippet for Formalicious by Sterc
*
* This utility snippet outputs all the steps for a multistep form
* based on a given form ID
*
* Usage:
* Put the snippet in your &stepTpl and call the snippet like this:
@christianseel
christianseel / MODX index.php
Created June 28, 2017 15:35
MODX index.php with XRouting integrated
<?php
/*
* This file is part of MODX Revolution.
*
* Copyright (c) MODX, LLC. All Rights Reserved.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@Azeirah
Azeirah / listLocales.php
Created December 26, 2016 23:10
List supported locales
<?php
// this list is large, but might not be completely exhaustive.
// I retrieved it from this stackoverflow answer: http://stackoverflow.com/a/20818686/2302759
// and added zh_TW
$locales = ["af_NA", "af_ZA", "af", "ak_GH", "ak", "sq_AL", "sq", "am_ET", "am", "ar_DZ", "ar_BH", "ar_EG", "ar_IQ", "ar_JO", "ar_KW", "ar_LB", "ar_LY", "ar_MA", "ar_OM", "ar_QA", "ar_SA", "ar_SD", "ar_SY", "ar_TN", "ar_AE", "ar_YE", "ar", "hy_AM", "hy", "as_IN", "as", "asa_TZ", "asa", "az_Cyrl", "az_Cyrl_AZ", "az_Latn", "az_Latn_AZ", "az", "bm_ML", "bm", "eu_ES", "eu", "be_BY", "be", "bem_ZM", "bem", "bez_TZ", "bez", "bn_BD", "bn_IN", "bn", "bs_BA", "bs", "bg_BG", "bg", "my_MM", "my", "ca_ES", "ca", "tzm_Latn", "tzm_Latn_MA", "tzm", "chr_US", "chr", "cgg_UG", "cgg", "zh_Hans", "zh_Hans_CN", "zh_Hans_HK", "zh_Hans_MO", "zh_Hans_SG", "zh_Hant", "zh_Hant_HK", "zh_Hant_MO", "zh_Hant_TW", "zh", "kw_GB", "kw", "hr_HR", "hr", "cs_CZ", "cs", "da_DK", "da", "nl_BE", "nl_NL", "nl", "ebu_KE", "ebu", "en_AS", "en_AU", "en_BE", "en_BZ", "en_
@sepiariver
sepiariver / cbGetLayoutSetting.snippet.php
Last active August 20, 2021 06:16
Gets a ContentBlocks Layout setting.
<?php
/**
* Use the cbGetLayoutSetting snippet to get a setting from a particular layout.
* @author YJ Tso @sepiariver <[email protected]>
* @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 required (int) &layout - ID of ContentBlocks layout from which to fetch the setting.
* @param required (string) &setting - key of layout setting to return.
*
@vidhav
vidhav / collections.imageplus.js
Last active April 12, 2024 11:43
Custom MODX Collections renderer for Image+
Collections.renderer.imageplus = function(value, metaData, record, rowIndex, colIndex, store) {
if (value != '' && value != null) {
var data = Ext.decode(value);
var url = MODx.config.connectors_url + 'system/phpthumb.php?imageplus=1';
var params = {};
params.src = MODx.config['collections.renderer_image_path'] + data.sourceImg.src;
params.w = 100;
if (data.sourceImg.src.indexOf('.png') !== -1) {
params.f = 'png';
@JensWolff
JensWolff / Get Core-Path | MODX Revolution API.php
Last active October 28, 2023 10:45
Get Core-Path (MODX Revolution API)
<?php
$this->modx->getOption('core_path');
@herooutoftime
herooutoftime / README.md
Last active May 13, 2022 15:55
MODx (missing) preview of unsaved changes

Idea & Concept

MODx Revolution lacks a preview of unsaved changes. For editors this is a rather important feature to check if their changes are correctly displayed and it's easy to do. No need to unpublish, save and view the resource. Just click 'Preview' and a MODx Window will show you all the changes.

The way it works is pretty easy: When clicking the 'Preview' button and OnBeforeDocFormSave is triggered all current (saved) data will be stored in a cache file, the resource will be saved with the new data. If OnWebPageComplete is fired, the saved data will be replaced with the previously cached data.

So for a short period the actual preview will be live!

Installation

@christianseel
christianseel / introRTE
Created August 14, 2014 14:52
RTE for introtext #modx
<?php
// Add RTE for introtext if richtext option is enabled for the resource
// check "OnDocFormRender" event
$modx->regClientStartupHTMLBlock('<script>Ext.onReady(function() {
if(MODx.loadRTE) MODx.loadRTE("modx-resource-introtext");
});</script>');
@LeaVerou
LeaVerou / dabblet.css
Created March 17, 2014 04:32
Gradient cheatsheet
/* Gradient cheatsheet */
background: linear-gradient(45deg, white, black);
background: linear-gradient(to right, white 50%, red, black);
background: linear-gradient(to bottom right, white 50px, black);
background: repeating-linear-gradient(to bottom left, white, black 30px);
background: radial-gradient(at top right, white, black);
background: radial-gradient(circle at top right, lime 50%, black 0);
background: radial-gradient(farthest-corner at center, red 80%, black);
background: radial-gradient(farthest-side at center, yellow 80%, black);