-
☆ A M B ☆
- 2,475 Posts
Is there an accessible parsing function for MODx Revo? Like if I have a string full of placeholders and I want to replace them with values... the standard stuff.
I can’t seem to find this anywhere. Even the $modx->getChunk() is somewhat obnoxious because it does too many things: it loads the chunk, AND parses it.
By the way, is there any text editor/EDI with autocompletion for modx objects ?
Netbeans does this if you’ve set up your MODx install as a project.
Use MODx, or the cat gets it!
-
☆ A M B ☆
- 3,141 Posts
Quote from: Everett at Nov 07, 2010, 10:37 PM
Is there an accessible parsing function for MODx Revo? Like if I have a string full of placeholders and I want to replace them with values... the standard stuff.
I can’t seem to find this anywhere. Even the $modx->getChunk() is somewhat obnoxious because it does too many things: it loads the chunk, AND parses it.
$placeholders = array (
'phname1' => 'value',
'phname2' => 'value2',
'phname3' => 'last value');
return $modx->getChunk($chunkname, $placeholders);
-
☆ A M B ☆
- 2,475 Posts
Mark -- that one API function is the one that suffers because it loads the chunk AND parses it. There are many cases where I need to separate the two actions, e.g. maybe it’s not a chunk that I’m parsing. This was an irksome point in the Evo API, too.
-
☆ A M B ☆
- 3,141 Posts
What would be a case where you’d need to seperate getting the chunk, and parsing the placeholders?
-
MODX Staff
- 10,725 Posts
All of the parsing power is in the modParser class, but parsing in MODx is not a simple, one pass, one API call type endeavor. It requires recursive, multi-stage lexical analysis that is aware of caching and when to quit trying to parse placeholders and remove them.
If you look in the process() method of any modElement (or modTag) derivative class, you will see the part that applies to a single element. But the majority of the parsing process starts with the Resource and ends in modResponse::outputContent(). So it really depends on what you are trying to accomplish with the manual parsing.
That said, IMO, manual parsing should (and can) be avoided in most cases, but let’s explore your intentions here to see what the best solution is.