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.