Skip to content

Instantly share code, notes, and snippets.

View sonicpunk's full-sized avatar

Benjamin Davis sonicpunk

View GitHub Profile
@christianhanvey
christianhanvey / modx-snippets.php
Last active June 14, 2023 13:02
Useful snippets for MODX Revo
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@jrotering
jrotering / rightTemplate
Last active December 17, 2015 03:59
Fires on 'OnHandleRequest' event. Sets the template of new resources based on a property in the template of the parent resource.
<?php
if (isset($_GET['a'])) {
$action = $modx->getObject('modAction', $_GET['a']);
if (is_object($action) && $action->get('controller') == 'resource/create') {
$parentID = isset($_REQUEST['parent']) ? (int) $_REQUEST['parent'] : 0;
if ($parent = $modx->getObject('modResource', $parentID)) {
$parentTpl = $parent->get('template');
if ($parentTplObj = $modx->getObject('modTemplate', $parentTpl)) {
if ($props = $parentTplObj->getProperties()) {
$tpl = ($ff = $modx->fromJSON($props['childTemplate'])) ? $ff : null;
@christianseel
christianseel / Chunk tabNavigationItem
Last active November 8, 2023 11:47
"generateTabs" output filter for ContentBlocks. See http://slides.com/christianseel/contentblocks/ 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>