We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1607
    • 72 Posts
    Now I do it.
    As I think I get xml information. I have message: Error reading the response: Invalid XML structure. And big window with my XML file. It’s OK! Thank you!
    Now I’ll try do right structure in js file.
      • 1122
      • 209 Posts
      Possible (and right) way for capturing ditto results in array is as follows:
      $ditto_params = array(
        'id' => 'myuniqueid', # !! very important
        'parents' => '3,5,13', # your desired parameters...
        'depth' => '1',
        'display' => 'all',
        'sortBy' => 'menuindex',
        'sortDir' => 'ASC',
        'tpl' => '@CODE:[+id+][+menuindex+][+content+]', # !! what to fetch
        'save' => '3' # !! do not output -- save results into placeholder
      );
      # call Ditto
      $modx->runSnippet('Ditto', $ditto_params);
      # read results (from placeholder set by ditto)
      $ph = $modx->getPlaceholder('myuniqueid_ditto_resource'); # !!! notice how resource identifier is built !!!
      

      $ph is an array of arrays that looks like
      $ph[0]['id'], $ph[0]['menuindex'], $ph[0]['content']
      $ph[1]['id'], $ph[1]['menuindex'], $ph[1]['content']
      $ph[2]['id'], $ph[2]['menuindex'], $ph[2]['content']
      ...
      

      Now you can easily walk through it with "for" or "foreach" and build whatever you want. Enjoy!
        • 1607
        • 72 Posts
        Thank you Alik!

        I’ll try do it
          • 1607
          • 72 Posts
          Hi, AHHP!

          I do as in your last post.
          And now some problems again!
          1. XML code created with xml.format.inc.php (format=xml) don’t want work in browser. There are my problem:
          - file create heder:
          -----------------------------------------------------------------
          <?xml version="1.0" encoding="" ?>
          -----------------------------------------------------------------
          there are no encode - in modx select UTF-8

          I insert encoding direct into xml.format.inc.php.
          File opened in browser without errors.

          Now 2 problem.
          When I create snippet and insert it to yhe blank document, I get tegs <p> and </p> in beginning and end of document.
          When XML file formed I see:
          -----------------------------------------------------------------
          <p><?xml version="1.0" encoding="UTF-8" ?>
          <xml version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
          <channel>
          ---
          body of document
          ---
          </channel>

          </xml>
          </p>
          -----------------------------------------------------------------
          And I get error message: XML declaration not at beginning of document

          What can I do?

            • 1122
            • 209 Posts
            Andrey, you need to set Content Type of your document to "text/xml" -- please see for this setting on Page Settings tab in the manager. Your error message looks like your document is being served through text/html template... And, what is important, also set the template of your document to "blank"...
              • 33992 ☆ A M B ☆
              • 455 Posts
              Hi Andrey_V smiley
              I guess you have inserted snippet code in your blank doc BY EDITOR (maybe TinyMCE) and it set snippet in a paragraph so your XML document got incorrect.
                God loves me. 【ツ】


                MODX.ir (Persian Support)

                Boplo.ir/modx/ (Persian)
                • 1607
                • 72 Posts
                Thank to all!!!
                I edit my document without editor and <p> was killed.
                And I change xmlHttp.responseXML to xmlHttp.responseText. No errors in my code now.
                All work beautiful!
                Thank you once more!!!