Skip to content

Instantly share code, notes, and snippets.

@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.

@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'
}
<...>
@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');
*/
if (!empty($options['showBoards'])) {
$c = array(
'board' => 0,
'groups' => $_groups,
);
if (!empty($scriptProperties['category'])) $c['category'] = (int)$scriptProperties['category'];
$cacheKey = 'discuss/board/user/'.$discuss->user->get('id').'/index-'.md5(serialize($c));
$boardIndex = $modx->cacheManager->get($cacheKey);
if (empty($boardIndex)) {
@Mark-H
Mark-H / gist:962492
Created May 9, 2011 13:14
Simple snippet (output filter) for MODX Revolution related items. Call as [[snippetname? &tpl=`chunkname` &input=`[[*your-comma-delimited-id-tv]]`]]
<?php
if ($input == null) { return 'No relevant items found.'; }
$tpl = $modx->getOption('tpl',$scriptProperties,null);
if (($tpl === null) || (!$modx->getChunk($tpl))) { return 'No template found'; }
$ids = explode (',', $input);
foreach ($ids as $a => $key) {
$document = $modx->getObject('modResource', array(
'published' => 1,
@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);
@avoronkin
avoronkin / MultipleTV.php
Created March 22, 2011 09:30
Multiple TV searching via xPDO
<?php
//http://modxcms.com/forums/index.php?topic=58644.msg354702#msg354702
$query->where(array(
array(
'id:IN' => $children_of_this_folder,
'published' => true,
'deleted' => false,
'hidemenu' => false,
'isfolder' => false,
@avoronkin
avoronkin / clientarea
Created January 20, 2011 17:01
autoClientArea
<?php
$adminId = 1;
$polisyID = 4;
$authorityLevel = 9999;
$extendedField = 'redirect';
//resorce setings
$template = 1;
$parent = 2;
$published = 1;
[ { "desc" : "Use the default parameter to have this Snippet redirect to the Resource specified in cases where there is no children. It can be a Resource ID or one of : site_start, site_unavailable_page, error_page, unauthorized_page.",
"desc_trans" : "Use the default parameter to have this Snippet redirect to the Resource specified in cases where there is no children. It can be a Resource ID or one of : site_start, site_unavailable_page, error_page, unauthorized_page.",
"lexicon" : null,
"menu" : null,
"name" : "default",
"options" : "",
"overridden" : false,
"value" : "site_start",
"xtype" : "textfield"
},
@ideesimple
ideesimple / gist:740511
Created December 14, 2010 14:46
récupère la position d'une ressource ainsi que le nombre de ressource de son parent
<?php
$count = 0;
$IdAvant='';
$IdApres='';
$position='';
$criteria = array(
'parent' => $parent,
'deleted' => false,
'published' => true,
);