We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    Hi All,

    Just to let you know where I am thus far in TP3.

    I’m working on some minor changes parser at the moment allow a snippet to make recursive calls to it self for upto a maximum of N levels, where N is set from within the index.php file.

    Consider the following DrawBox snippet:

    global $boxWidth;
    global $left;
    
    if(empty($left)) $left = 0;
    if(empty($boxWidth)) $boxWidth = 200;
    
    $col[0] = rand(1,255);
    $col[1] = rand(1,255);
    $col[2] = rand(1,255);
    $boxWidth -= 10;
    $left += 5;
    
    $color = "#c0c0c0";//.dechex(($col[0]<<16)|($col[1]<<8)|$col[2]);
    
    echo '<div style="left:'.($left+200).'px; top:'.($left+200).'px; width:'.$boxWidth.'px; height:'.$boxWidth.'px; border:1px solid '.$color.';position:absolute;"></div>[[DrawBox]]';
    


    This will draw up to 10 boxes by reducing the height and width with each recursive call as show below:


    This additional feature will not add any overhead to the parser. It will only process resources on as needed basis. In other words it will not loop or process the document 10 times if there is no resource (snippet, chunk, tv, etc) to be processed.

    Earlier versions of MODx could only achive this by using the $snippetParsePasses which would have to loop through the document "$snippetParsePasses" number of even it there’s nothing to parse.



      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 25663 MODX Staff
      • 12,272 Posts
      That’s really cool. Would the same "self-recursion" happen whith snippets calling other snippets that call other snippets, etc., or is it only for the same-snippet calls?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 32963
        • 1,732 Posts
        Quote from: rthrash at Jul 10, 2005, 10:00 AM

        That’s really cool. Would the same "self-recursion" happen whith snippets calling other snippets that call other snippets, etc., or is it only for the same-snippet calls?

        It would happen either way. That is Snippets calling other snippets or resources, TVs calling other TVs or resources, Chunks calling other resources, etc.

          xWisdom
          www.xwisdomhtml.com
          The fear of the Lord is the beginning of wisdom:
          MODx Co-Founder - Create and do more with less.