Posted By


chucktrukk on 02/16/08

Statistics


Viewed 548 times
Favorited by 0 user(s)

mergeDocumentContentX


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /* Parse all TVs in the [content] of a document. $doc_id is the id of the document */
  2. function mergeDocumentContentX($doc_id) {
  3. global $modx;
  4.  
  5. $my_doc = $modx->getTemplateVarOutput('*',$doc_id);
  6. $template = $my_doc['content'];
  7.  
  8. $replace= array ();
  9. preg_match_all('~\[\*(.*?)\*\]~', $template, $matches);
  10. $variableCount= count($matches[1]);
  11. $basepath= $modx->config["base_path"] . "manager/includes";
  12. for ($i= 0; $i < $variableCount; $i++) {
  13. $key= $matches[1][$i];
  14. $key= substr($key, 0, 1) == '#' ? substr($key, 1) : $key; // remove # for QuickEdit format
  15. $value = $my_doc[$key];
  16. if (is_array($value)) {
  17. include_once $basepath . "/tmplvars.format.inc.php";
  18. include_once $basepath . "/tmplvars.commands.inc.php";
  19. $w= "100%";
  20. $h= "300";
  21. $value= $modx->getTVDisplayFormat($value[0], $value[1], $value[2], $value[3], $value[4]);
  22. }
  23. $replace[$i]= $value;
  24. }
  25. $template= str_replace($matches[0], $replace, $template);
  26. //return $template;
  27.  
  28. $return_vals = array("my_doc" => $my_doc, "template" => $template);
  29. return $return_vals;
  30. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.