Skip to content

Instantly share code, notes, and snippets.

@pepebe
pepebe / contextKey.snippet.php
Last active October 14, 2018 19:04
Retrieve Context Key inside snippets. See https://forums.modx.com/thread/30357/solved-return-the-current-context-key for more details.
<?php
/*
* Usage [[!contextKey]]
* */
return $modx->context->key;
@pepebe
pepebe / Messages
Created May 12, 2017 21:19 — forked from sottwell/Messages
Dashboard Widget to display the number of internal Manager messages the user has - MODX Revoluition
// Dashboard widget to show number of Manager messages
$id = $modx->user->get('id');
$output = 'No messages.';
$total = $modx->getCount('modUserMessage',array(
'recipient' => $id,
));
if($total) {
$output = 'You have ' . $total . ' messages';
$unread = $modx->getCount('modUserMessage',array(
'recipient' => $id,
@pepebe
pepebe / plugin.createdOnBy.php
Last active May 2, 2022 12:27
Add createdon and createdby to settings tab
<?php
/**
* Sample plugin to add a "createdby and createdon" field on a resource form
* Background: Issue #12305 "Adding createdon/createdby/publishedby/etc. to settings"
* https://github.com/modxcms/revolution/issues/12305
*
* Original author: rtripaul
* Original source: https://gist.github.com/rtripault/7306c8487a39fd1ce0db5f334c99be57
*
* @var modX $modx
@pepebe
pepebe / Chunk tabNavigationItem
Last active June 6, 2019 10:41 — forked from christianseel/Chunk tabNavigationItem
"generateTabs" output (Bootstrap 3.x) filter for ContentBlocks. See http://sedadigital.slides.com/sedadigital/contentblocks2#/4/6 for instructions.
<li class="tab-title [[+idx:is=`1`:then=`active`:else=``]]" role="presentational">
<a href="#[[+id]]" role="tab" tabindex="0" aria-selected="false" controls="[[+id]]">[[+title]]</a>
</li>
@pepebe
pepebe / image.tpl
Created March 3, 2017 16:28 — forked from JensWolff/image.tpl
Quick'n'Dirty MODX 2.3.x image-TV-clearbutton (/manager/templates/default/element/tv/renders/input/image.tpl)
<style>
.clearImageTV + .x-panel.modx-panel.x-panel-noborder{
margin-left: 30px;
margin-top: -34px;
}
</style>
<div id="tvbrowser{$tv->id}"></div>
<div id="tv-image-{$tv->id}"><a class="clearImageTV" href="#" onclick="javascript:Ext.getCmp('tvbrowser{$tv->id}').setValue('');document.getElementById('tv{$tv->id}').value='';document.getElementById('tv-image-preview-{$tv->id}').getElementsByTagName('img')[0].remove();"><i class="icon icon-2x icon-trash-o"></i></i></a></div>
@pepebe
pepebe / redirect.html
Created February 23, 2017 07:05
Simple redirect page for modx.
<!doctype html>
<html lang="en">
<head>
<title>[[*pagetitle]] - [[++site_name]]</title>
<base href="[[!++site_url]]" />
<meta charset="[[++modx_charset]]" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta http-equiv="refresh" content="0; URL=https://artmetropol.tv/">
@pepebe
pepebe / pepebe_updateSystemSettings.snippet.php
Last active March 1, 2017 16:08
This snippet will edit/add a number of settings to modx_system_settings.
<?php
/*
* This snippet will edit/add a number of settings to modx_system_settings.
* The $settings array MUST contain all relevant information.
* Use the example below to create your own list of relevant settings.
*
* Updating settings
* -----------------
* All settings allready present in the database are updated by this script.
* Keep in mind to send the correct type of data. So don't add "hello" to a key with xtype "combo-bolean".
@pepebe
pepebe / ppbCarousel.snippet.php
Last active February 17, 2017 15:01
Return id of a sibling document. Useful to build carouse navigations.
<?php
/*
ppbCarousel returns ids of specific sibling resources.
It can be used to build prev next links.
If the current Resource is at the beginning or the end of the list,
prev and next will circle to the first or last element.
[[ppbCarousel?
@pepebe
pepebe / ppb_ImageInfo.snippet.php
Last active February 4, 2017 18:57
Return useful image properties as placeholders. Available properties are height, width, type, attribute, orientation and file size. Can be used as an output filter or as standard snippet.
<?php
/*
ppb_ImageInfo
v0.1
2017-02-04 19:45
by info@pepebe.de
This is a MODx snippet. Use it as an output filter or as a standard snippet:
<?php
if(!function_exists(autoRotateImage)) {
function autoRotateImage($image) {
$orientation = $image->getImageOrientation();
switch($orientation) {
case imagick::ORIENTATION_BOTTOMRIGHT:
$image->rotateimage("#000", 180); // rotate 180 degrees
break;