Skip to content

Instantly share code, notes, and snippets.

@larscwallin
Created June 23, 2011 08:47
Show Gist options
  • Save larscwallin/1042165 to your computer and use it in GitHub Desktop.
Save larscwallin/1042165 to your computer and use it in GitHub Desktop.
MODx toPlaceholders wrapper
<?php
/*
Snippet "simplx_toplaceholders"
KISS Snippet which wraps the $modx equivalent, only adds the ability to use JSON input.
Example:
[[!simplx_toplaceholders?&subject=`{"typename":"person","name":"Joe Snippetson","address":{"street":"Next Street 5","zip":"55 555","city":"Utopia"}}`]]
<br/>Name:<br/>
[[+name]]
<br/>Address:<br/>
[[+address.street]]
<br/>
[[+address.zip]] [[+address.city]]
---------------------------------------------------------------------------
The subject parameter could of course be any Chunk or Snippet or String :)
*/
if(!$subject){
return '';
}
$subject = json_decode($subject,true);
$prefix = isset($prefix) ? $prefix : '';
$separator = isset($separator) ? $separator : '.';
$modx->toPlaceholders($subject,$prefix,$separator);
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment