Skip to content

Instantly share code, notes, and snippets.

@rtripault
rtripault / Form.tpl
Created October 31, 2010 17:08
Building an "advanced search" with MODx Revolution, SimpleSearch & getReqParam
<form class="sisea-search-form" action="[[~[[+landing:default=`[[*id]]`]]]]" method="[[+method:default=`get`]]">
<fieldset>
<label for="[[+searchIndex]]">[[%sisea.search? &namespace=`sisea` &topic=`default`]]</label>
<input type="text" name="[[+searchIndex]]" id="[[+searchIndex]]" value="[[+searchValue]]" />
<select name="parent" id="parent">
<option value="0">All the website (0 = root)</option>
<option value="34">Section 1 (parent resource ID=34)</option>
<option value="27">Section 2 (parent resource ID=27)</option>
<option value="5">Section 3 (parent resource ID=5)</option>
@rtripault
rtripault / checkLexicon.php
Created October 31, 2010 21:55
Check MODx Revolution lexicon files (by Hansek, source : http://modxcms.com/forums/index.php/topic,50565.0.html)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Updated for MODx Revo by: Hansek http://www.modxcms.cz/ hansek@coex.cz
Created for MODx Evo by : Coroico (http://modx.wangba.fr)
Short Description: Language files checking tool for MODx Revolution
Version: 1.2
Created by: Coroico (http://modx.wangba.fr)
@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=``
@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=``
[[ (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: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)
@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 / 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 / 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 / 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');