Skip to content

Instantly share code, notes, and snippets.

<?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)) {
<?php
$debug = $modx->getOption('debug', $scriptProperties, false);
if ($debug) {
$modx->setLogLevel(modX::LOG_LEVEL_DEBUG);
}
//new user object
$user = $modx->newObject('modUser');
//get all form fields
$formFields = $hook->getValues();
<?php
$docArray = $modx->getCollection('modResource');
foreach($docArray as $doc) {
$doc->joinGroup('GroupName');
}
<?php
/**
* This is a MODX snippet to add "new" or "Updated" images to menu,
* pages and such.
* You need to provide your own new.gif and updated.gif file. change the
* file path to the images files accordingly.
* if called without input parameter then it will look at the page resource and
* determine if the page is newly published or updated.
* if called with input=`resourceID` then it will look into that resource ID.
* This snippet can be also used with getResoruces or Wayfinder.
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
<?php
if ($debug) {
$modx->setLogLevel(modx::LOG_LEVEL_DEBUG);
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;
}
<?php
/*** GetTemplate ***/
include MODX_CORE_PATH . 'custom/templates/' . $modx->resource->template . '.html';
return;
/*** Include ***/
$chunk = $modx->getOption('chunk', $scriptProperties, false);
<?php
$doodle = $modx->getService('doodles','Doodles',$modx->getOption('doodles.core_path',null,$modx->getOption('core_path').'components/doodles/').'model/doodles/');
if (!($doodle instanceof Doodles)) {
$hook->addError('error_message','Unable to load doodle service.');
return false;
};
$newEntry = $modx->newObject('Doodle');
$newEntry->fromArray($scriptProperties['fields']);
<?php
/**
* CercecUser
*
* @author Marc Elie <marc.elie77@gmail.com>
*
* Event: OnUserFormSave
*
* Modified from Bob Ray's plugin tutorial, Official Guide p. 492-3
* and Bob Ray's online explanation on create class:
<?php
/**
* @package = CreateXpdoClasses
*
* Create Xpdo Classes script
*
* This script creates xPDO-ready classes from existing custom
* database tables. It only needs to be run once.
*
* It assumes that your custom tables have been imported into