We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25154
    • 43 Posts
    I’m trying to create a page that displays an XML representation of the document tree. I’ve come somewhat close by reading a similar MODX post located here: http://modxcms.com/forums/index.php?topic=53371.0

    The reason for this is for the Gaia Flash Framework. I’m trying to use MODX for my Flash Progressive Enhancement CMS.

    The output XML I’m trying to accomplish looks something similar to this:

    <site title="Site Scafold: %PAGE%" menu="true">
      <page id="index" src="index.swf" bytes="22294">
        <page id="nav" src="nav.swf" depth="top" bytes="22294">
          <page id="home" title="Home" src="home.swf" menu="true" bytes="22296"/>
          <page id="products" src="products.swf" bytes="51212">
            <page id="product1" title="Product1" src="Product1.swf" menu="true" bytes="51194"/>
            <page id="product2" title="Product2" src="product2.swf" menu="true" bytes="51279"/>
          </page>
        </page>
      </page>
    </site>
    


    What I can’t figure out is how is the recursion portion. How to place the pages inside folders... Now my snippet below may be WAY off base, but it’s my first attempt and get’s me close, but not all the way. What the snippet below creates is this:

    <site>
    <page id="page1" src="page1.src" menu="true"/>
    <page id="page2" src="page2.swf" menu="true"/>
    <page id="products" src="products.swf" menu="true"/>
    <page id="home" src="home.swf" menu="true"/>
    </site>
    


    The SiteXML Snippet Code So Far:
    <?php
    $gR_output = $modx->runSnippet( 'getResources2', array(
      "parents" => "0",
      "includeTVs" => "1",
      "processTVs" => "1"
        ));
    
      $gR_output = explode('|', $gR_output); // extract serialized data
      foreach( $gR_output as $item ) {
        $unserialized = unserialize( base64_decode( $item )); // expand data
        if ( is_array( $unserialized )) {
          $gR_array[] = $unserialized;
        }
    
      /* add your custom code logic here */
      }
    
    //iterate over each resource and print out Gaia XML
    $GaiaXML = "<site>";
    
    foreach($gR_array as $singleresource) {
      //iterate over each resource item
      $GaiaXML .= "<page ";
      
      $testnum = 0;
      foreach($singleresource as $resourceitem => $value) {
        
        //test
        //$GaiaXML .=  " ResourceItem". $testnum + 1 ."='" . $resourceitem . "' Value='" . $value . "' ";
        
        if($resourceitem == 'isfolder') {
        } 
        
        if($resourceitem == 'tv.Gaia ID') {
          $GaiaXML .= "id='" . $value . "' ";
        }
        
        if($resourceitem == 'tv.Gaia SRC') {
          $GaiaXML .= "src='" . $value . "' ";
        }
        
        if($resourceitem == 'tv.Gaia Other') {
          $GaiaXML .=  $value;
        }
      }
      $GaiaXML .= " />";
    }
    
    $GaiaXML .= "</site>";
    
    
    
    //finaly display XML
    echo $GaiaXML;
    ?>
    

    Can anyone out there help?
      • 25154
      • 43 Posts
      Can anyone out there help me? smiley