-
MODX Staff
- 12,272 Posts
I’m guessing that the reason is the match only works once and is not recursive at all. Hence the discussion in the other thread.
The reason the single-nested works with an uncached snippet is because it’s matching on a different syntax: [[ vs. [!.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
I discovered another somewhat similar one.
The code was this:
[!MenuBuilder?startID=[*lang*]!]
Now I wanted to see what time it took to execute the MenuBuilder, or in fact, what happened if I _cached_ the page, and called it like:
[[MenuBuilde?startID=[*lang*]]]
This didn’t work, so I restored to the previous way of calling the snippet, after I cleared all the cached pages.
Still, the problem was there that the [*lang*] call returned the wrong value!
Could this probably come due code in siteCache.idx.php which isn’t refreshed?
Should I make a bugreport?
Greetz,
Remon
-
MODX Staff
- 12,272 Posts
Sounds like a bug report to me Remon. Thanks.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
Hi Remon,
Note you have [[MenuBuilde?startID=[*lang*]]] is that a typo?
Also note that once you cache the page the [[]] will one be executed the first time the page is generated.
Using [!!] when the page is cached will always execute the snippet code but [**] will remain a cached value.
Hmmm,
I’m thinking that we could a custom syntax analyser that’s capable of looking through the code and executing each [[]] at a time.
I’m thinking we could use strpos, substr and str_replace
example:
function name: mergeTag(&$html, $startpos=0)
* let st = position of [[
* if st>=0 then let et = position of ]] from st+2
* let nst = position of [[ from st+2
if nst < et then
mergeTag($html,st+2)
et = position of ]] from st+2
end if
if et>st then let tag = substr(st,et-st+2)
$html = str_replace(tag,processTag(tag),$html)
I’m not sure how fast this function would work but I think it will be able to process the tags in a the order they appear in the page.
for example:
[[A?
&p1=`[[B? &p1=`[[C]]` ]]`
]]
The execution order would be C, B then A
What what you you think? Anyone want to give it a try?