Hello Everyone,
In an effort to bring get the best out of MODx I’ve just spent serveral hours trying to fix a bug detected when parsing multiple/nested/cached/non-cacheable tags! It was a nightmare! The good new however is that it’s more intelligent than before. I call it P
2:
Consider the following tag:
[[A? &p1=`[[B? &p1=`[[C]]` &p2=`[[D]]`]]` &p2=`[[B? &p1=`[[E]]` &p2=`[[F]]`]]`]]
If [[E]] was maded non-cacheable the parser would be intelligent enough to detect this and force tags [[A]] and [[ B]] to be non-cacheable as well. This means that the values of [[E]] will always be passed to [[ B]] as shown below:
[[A? &p1=`3` &p2=`[[B? &p1=`[[E]]` &p2=`8`]]`]]
All the other tags will be parsed and passed in as static values with the exception of [[E]].
As a result of this intelligence the parser is now able to support parallel parsing on multiple levels of cached vs non-cacheable tags:
Consider where [[E]] is set to non-cacheable:
[[A? &p1=`[[B? &p1=`[[C]]` &p2=`[[D]]`]]` &p2=`[[B? &p1=`[[E]]` &p2=`[[F]]`]]`]]
[[E]] [[ B]] [[E]]
[[A? &p1=`[[B? &p1=`[[C]]` &p2=`[[D]]`]]` &p2=`[[B? &p1=`[[E]]` &p2=`[[F]]`]]`]]
This will result in a cached output of:
[[A? &p1=`3` &p2=`[[B? &p1=`[[E]]` &p2=`8`]]`]]
[[E]] 15 [[E]]
[[A? &p1=`22` &p2=`[[B? &p1=`[[E]]` &p2=`27`]]`]]
Note here that the [[E]] tag generates an output of embedded tags [[G]] [[H]] [[I]]. If we were to only set [[H]] as a non-cacheable tag the parser would render the follow:
10
11 12 [[H]] 14 15 16 17 [[H]] 19
29
If we were to set both [[A]] and [[H]] as a non-cacheable tag the parser would render the follow:
[[A? &p1=`3` &p2=`[[B? &p1=`4 5 [[H]] 7` &p2=`8`]]`]]
11 12 [[H]] 14 15 16 17 [[H]] 19
[[A? &p1=`22` &p2=`[[B? &p1=`23 24 [[H]] 26` &p2=`27`]]`]]
The tags used above represents complex layouts that are now possible with the new parser engine. Most day to day designs will not require such complex layouts but it only goes to reveal the true power of the MODx system
What do you think?