Skip to content

Instantly share code, notes, and snippets.

@mkschell
mkschell / context_directory_binding.php
Created May 16, 2011 17:17
emulate @Directory binding, but from base_path of Resource's context #MODX
<?php
/**
* emulate @DIRECTORY binding, from base_path of Resource's context
*
* usage:
* a) create context settings named 'base_path' for each context (not neccessary for web context)
* (note: you may also want assets_path and/or other settings in your contexts as well)
* b) call with @EVAL in TV's Input Options field, e.g.
* @EVAL $dir='assets/images/'; return(include '/path/to/this/file/context_directory_binding.php');
*/
@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 / readme.md
Created May 31, 2011 22:29
Create database tables for VisionCart in MODX 2.1+

Use this little snippet to create database tables from the visioncart model to actually use the package when freshly installed.

Put the code in a new snippet, and put the snippet call in any resource. Visit the resource. Try using VisionCart or check your database using PhpMyAdmin to see if the tables were created.

@lossendae
lossendae / linked_combobox.js
Created June 8, 2011 09:50
Combobox linké
var firstCombo = new Ext.form.ComboBox({
store: store_combo_1,
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
id:'combo1'
});
@larscwallin
larscwallin / gridFilter.js
Created June 8, 2011 21:55
ExtJs Grid filter
/**
* Ext.ux.grid.GridFilters v0.2.8
**/
Ext.namespace("Ext.ux.grid");
/* PATCH http://extjs.com/forum/showthread.php?t=76280 */
Ext.override(Ext.grid.GridView, {
handleHdMenuClick : function(item){
var index = this.hdCtxIndex,
cm = this.cm,
/*!
* Ext JS Library 3.2.1
* Copyright(c) 2006-2010 Ext JS, Inc.
* [email protected]
* http://www.extjs.com/license
*/
Ext.onReady(function(){
Ext.QuickTips.init();
@splittingred
splittingred / gist:1018793
Created June 10, 2011 13:05
Hide left trees in MODX Revolution
Ext.onReady(function() {
Ext.getCmp('modx-layout').hideLeftbar();
});
<?php
if ($modx->event->name == 'OnManagerPageInit') {
$script = <<<SCRIPT
<script type="text/javascript">
Ext.ComponentMgr.onAvailable('modx-panel-resource', function(){
Ext.getCmp('modx-panel-resource').on('ready', function(){
window.setTimeout(function(){Ext.getCmp('modx-panel-resource').markDirty()}, 250);
})
})
</script>
@anselmh
anselmh / prerender-avoid-ga.js
Created June 27, 2011 09:15
prerender-avoid-ga
// if you have analytics, set them in pagevisibility mode to get real-user-trackig according to prerender-issues in Chrome/WebKit.
var viewCounted = false;
function handleVisibilityChange(evt) {
//Only count the view once we're done prerendering AND the document is done loading
if (document.webkitVisibilityState == 'prerender'
|| document.readyState != 'complete' || viewCounted)
return;
/* Implementation of view counting system starts here */
// Code for Google Analytics | Change UA-XXXXX-X to be your site's ID
@splittingred
splittingred / prehook.profile.php
Created August 26, 2011 17:48
PreHook for FormIt to load User data into form
<?php
if (!$modx->user->hasSessionContext($modx->context->get('key')) return '';
$userArray = $modx->user->toArray();
$profile = $modx->user->getOne('Profile');
if ($profile) {
$userArray = array_merge($profile->toArray(),$userArray);
$extended = $profile->get('extended');
if (!empty($extended) && is_array($extended)) {