-
-
Save Mark-H/1042279 to your computer and use it in GitHub Desktop.
MODx toPlaceholders wrapper
This file contains 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 = $modx->fromJSON($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
See my fork for a fix in your example.. also changed jsondecode to the modx equivalent (fromJSON) which works even if the server doesn't support json* functions :P