We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3036
    • 6 Posts
    Hi guy’s i’am wondering how it is possible to check the content of the current document and if it is empty then
    load the content of another document and put it in the content zone of the current document.

    exemple :

    $doc = $modx->getDocumentObject(’id’,$docid);
    $contenu = $doc[’content’];
    ...
    ...
    // Taking the content from the other document ...
    objects = $modx->getDocumentObject(’id’,$docid2);
    $contAct = $objects[’content’];
    ...
    ...
    if ($contenu == ""){
    // Injecting the new content in the current document [*content*] zone
    $modx->setPlaceHolder(’content’, $contAct);
    }
      • 3749
      • 24,544 Posts
      Quote from: bekergu at Feb 22, 2008, 10:17 AM

      Hi guy’s i’am wondering how it is possible to check the content of the current document and if it is empty then
      load the content of another document and put it in the content zone of the current document.

      exemple :

      $doc = $modx->getDocumentObject(’id’,$docid);
      $contenu = $doc[’content’];
      ...
      ...
      // Taking the content from the other document ...
      objects = $modx->getDocumentObject(’id’,$docid2);
      $contAct = $objects[’content’];
      ...
      ...
      if ($contenu == ""){
      // Injecting the new content in the current document [*content*] zone
      $modx->setPlaceHolder(’content’, $contAct);
      }

      It might be safer to just redirect them to the other document if the current one is empty.

      Wouldn’t it be easier just to make sure that all your documents have some content in them? huh

      Bob
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting