pepebe
6/23/2011 - 9:56 AM

MODx toPlaceholders wrapper

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 = $modx->fromJSON($subject,true);
$prefix = isset($prefix) ? $prefix : '';
$separator = isset($separator) ? $separator : '.';
$modx->toPlaceholders($subject,$prefix,$separator);
return;