Skip to content

Instantly share code, notes, and snippets.

@opengeek
opengeek / recalculateURIs.php
Created April 13, 2011 14:47
Script to recalculate all unfrozen URI values for MODX Resources in 2.1.x+
<?php
include 'config.core.php';
include MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
@Mark-H
Mark-H / 1. In the ExtJS form declaration.js
Created May 21, 2011 21:53
Fancy MODX / ExtJS combo-box that searches while typing and adds new entries if they don't exist.
// Call the form with the unique xtype
items: [{
xtype: 'campermgmt-newcamper-form-brandscombo',
fieldLabel: 'Merknaam',
name: 'brand',
id: 'brand',
allowBlank: false,
vtype: 'alphanum'
}
<...>
@Mark-H
Mark-H / disabletooltips.plugin.php
Last active March 1, 2016 22:15
Plugin to disable tooltips in MODX globally.
<?php
// Disables tooltips globally.
//
// Create a new plugin and add the following system event: OnManagerPageInit
//
// © 2010 Mark Hamstra <hello@markhamstra.com>
// Buy me a beer? Paypal hamstra.mark at gmail.com.
//
// Licensed under the MIT license
@digibutt
digibutt / gist:1228932
Created September 20, 2011 11:55
Log a hit in a plugin in MODX
$tv = $modx->getObject('modTemplateVar', array('name' => 'hitcount'));
$criteria = array(
'tmplvarid' => $tv->get('id'),
'contentid' => $modx->resourceIdentifier
);
if(!$tvResource = $modx->getObject('modTemplateVarResource', $criteria)){
$tvResource = $modx->newObject('modTemplateVarResource');
$tvResource->set('value', 1);
@Rob-ot
Rob-ot / Draggable.js
Created December 16, 2011 23:46
Draggable and dropable views for backbone, uses html5 drag and drop api, requires jquery and underscore, not tested in IE yet
return View.extend({
initialize: function () {
this.el.attr("draggable", "true")
this.el.bind("dragstart", _.bind(this._dragStartEvent, this))
},
_dragStartEvent: function (e) {
var data
if (e.originalEvent) e = e.originalEvent
e.dataTransfer.effectAllowed = "copy" // default to copy
@edbo
edbo / lexiconToCsv.php
Created January 25, 2012 08:16
Php snippet to output lexicon file to csv
<%php
$fp = fopen('file.csv', 'w');
foreach ($_lang as $key => $field) {
fputcsv($fp, array(
'key' => $key,
'field' => $field
));
}
fclose($fp);
@jaygilmore
jaygilmore / TinyMCECustomToolbar.txt
Created March 21, 2012 18:45
TinyMCE Minimal Custom Toolbar for MODX. Gives end users just the tools they need to create and publish content—nothing more.
formatselect,styleselect,bold,italic,underline,bullist,numlist,pastetext,image,modxlink,unlink,anchor,media,removeformat,separator,code,help
@splittingred
splittingred / .htaccess
Created April 9, 2012 21:48
Example of how to use new REST server class in MODX 2.3+
<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>
@goldsky
goldsky / autoload.fancybox.js
Created April 13, 2012 04:45
This snippet loads fancybox automatically to all images inside the #content area. Useful for user's images that are uploaded by TinyMCE.
$(document).ready(function() {
$("#content img").wrap(function() {
return '<a href="'+ this.src +'" />';
}).parent().fancybox();
});
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter