Skip to content

Instantly share code, notes, and snippets.

@rtripault
rtripault / getAside.php
Created February 9, 2011 00:28
getResources tweaked to sort by resources order (to use with the sortable checkbox TV)
<?php
/**
* getResources
*
* A general purpose Resource listing and summarization snippet for MODx 2.0.
*
* @author Jason Coward
* @copyright Copyright 2010, Jason Coward
* @version 1.2.2-pl - October 18, 2010
*
<?php
$modx->sendRedirect($modx->makeUrl($id, '', '', 'full'));
@rtripault
rtripault / Input Option Values :
Created November 25, 2010 09:51
MODx Revolution snippet to list resources of a given parent in order to output it in Option Values of a TV
@EVAL return $modx->runSnippet('getAside');
@rtripault
rtripault / getMany
Created November 16, 2010 17:18
The following code allows the retrieval of child document for the page the user is on. (source: http://www.unchi.co.uk/2010/11/16/modx-revolution-getmany-children/)
$criteria = $modx->newQuery('modResource');
$criteria->where(array(
'parent' => $modx->resource->get('id'),
'published' => 1,
'deleted' => 0,
));
$criteria->sortby('pagetitle','ASC');
$children = $modx->resource->getMany('Children',$criteria);
foreach($children as $var => $value)
{
@rtripault
rtripault / multi.snippet.php
Created November 12, 2010 04:19
Link to translated resource (or homepage if no translation available) for MODx Revolution
<?php
// if we are in context www-en…
if ($modx->context->get('key') == "www-en") {
$o = '';
// …grab www-fr infos
$modx->switchContext('www-fr');
$ss = $modx->getOption('site_start');
$ctx = $modx->context->get('key');
// grab datas from TV named multi (containing ID of the translated resource)
$tvv = $modx->resource->getTVValue('multi');
@rtripault
rtripault / gist:670891
Created November 10, 2010 14:12
SimpleSearch parameters (MODx Revolution)
[[simpleSearch?
&tpl=`SearchResult`
//The chunk that will be used to display the contents of each search result.
&containerTpl=`SearchResults`
//The chunk that will be used to wrap all the search results, pagination and message.
&useAllWords=`0`
//If true, will only find results with all the specified search words.
&maxWords=`7`
//The maximum number of words to include in the search. Only applicable if useAllWords is off.
&searchStyle=`partial`
@rtripault
rtripault / gist:666112
Created November 7, 2010 12:58
Syntax exemple(s) to use &where param with MODx getResources
&where=`{ "template:IN" : [ 1,2,3 ] }
&where=`{ "template:NOT IN" : [ 1,2,3 ] }
&where=`{{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}}` (source: http://modxcms.com/forums/index.php?topic=52307.0)
[[ (opening tags)
! (optional non-cacheable flag)
elementToken (optional token identifying the element type if it's not a snippet, $=chunk, *=resource field/tv, +=placeholder, etc.)
elementName
@propertyset (optional PropertySet identifier)
:filterName=`modifier`:... (optional one or more output filters)
? (optional; indicates beginning of property string)
&propertyName=`propertyValue` &... (optional; any additional properties separated by &)
]] (closing tags)
@rtripault
rtripault / gist:662919
Created November 4, 2010 18:37
MODx Revolution Wayfinder parameters
[[!Wayfinder?
&removeNewLines=`0`
&where=``
&hereId=``
&templates=``
&config=``
&StartId=`0`
&level=`1`
&includeDocs=``
@rtripault
rtripault / gist:662895
Created November 4, 2010 18:20
MODx Revolution getResources parameters
[[!getResources?
&parents=``
&resources=``
&depth=`0`
&tvFilters=``
&sortby=`menuindex`
&sortbyAlis=``
&sortbyEscaped=``
&sortdir=`ASC`
&limit=``