Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: None  |  size: 0.77 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. /*
  4.  
  5. Snippet "simplx_toplaceholders"
  6.  
  7. KISS Snippet which wraps the $modx equivalent, only adds the ability to use JSON input.
  8.  
  9.  
  10. Example:
  11.  
  12. [[!simplx_toplaceholders?&subject=`{"typename":"person","name":"Joe Snippetson","address":{"street":"Next Street 5","zip":"55 555","city":"Utopia"}}`]]
  13.  
  14. <br/>Name:<br/>
  15. [[!+name]]
  16.  
  17. <br/>Address:<br/>
  18. [[!+address.street]]
  19. <br/>
  20. [[!+address.zip]] [[!+address.city]]
  21.  
  22. ---------------------------------------------------------------------------
  23.  
  24. The subject parameter could of course be any Chunk or Snippet or String :)
  25.  
  26. */
  27.  
  28. if(!$subject){
  29.         return '';
  30. }
  31.  
  32. $subject = $modx->fromJSON($subject,true);
  33. $prefix = isset($prefix) ? $prefix : '';
  34. $separator = isset($separator) ? $separator : '.';
  35. $modx->toPlaceholders($subject,$prefix,$separator);
  36. return;