Created
June 23, 2011 08:47
-
-
Save larscwallin/1042165 to your computer and use it in GitHub Desktop.
MODx toPlaceholders wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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