I’m trying to figure out why Jot placeholders don’t work when the PHx plugin is installed and enabled. I thought I had it, but had a check in the wrong place in the loop. There has to be a reason, though.
-
- 209 Posts
Both PHx parsers, Jot’s internal and standalone, have the same code and were written by the same author. The fundamental thing for understanding your issue, IMO, is that the PHx parser cleans up unresolved tags with PHx modifiers attached.
What unresolved tag is? It is a placeholder that the actual value has not been set for.
Standalone PHx parser is executed on ParseDocument event. At this stage of processing none of Jot’s placeholder -- if it appears in parsed code -- has its value set and therefore all such tags are removed (as unresolved).
Why Jot’s placeholders are properly processed by Jot’s internal PHx parser? Because prior to running internal PHx parser, Jot sets actual values for its tags by calling $instance->setPHxVariable($name, $value) method of the PHx class.
In order to force MODx (with standalone PHx parser enabled) for proper processing of Jot’s placeholders, all such placeholders should be taken from their "current level" of code and hidden a "level deeper", into chunks that will be processed in "Jot’s phase" (by internal parser with prior assignment of actual values), not earlier.
Hope you got what I mean.
Yes, I figured this out a few days ago. I still think it’s rather presumptuous of the plugin to eat everybody’s placeholders. One would think that it would stick to its own [+phx:...+] placeholders.
Another solution is to run the snippet setting the placeholders uncached on an uncached page, that way the snippet’s placeholders are set and merged before the plugin so helpfully does its garbage collection.
(reminds me of the Robert the Plant iteration where he was set out early to get some sun, but it was trash day and he got hauled off with the rest of the trash)
-
- 77 Posts
Hmm... is there a solution for using the Jot placeholders while having PHx activated? I have the problem, that when calling Jot cached (via chunk or directly in the template), anonymous users will see the moderation stuff. I didn’t figure out how to solve this
[[Jot? &output=`0` &placeholders=`1` &sortby=`createdon:a` &numdir=`0` &subscribe=`0` &captcha=`1` &moderated=`0` &guestname=`Unbekannt` &tplForm=`iiiCommentsPost` &tplComments=`iiiCommentsRead` &tplModerate=`iiiCommentsMod`]]
[+jot.html.moderate+]
<div class="contentblock_8 news">
<h2>Kommentare</h2>
[+jot.html.comments+]
</div>
[+jot.html.form+]
MODx 1.0.3 / Jot 1.1.4 / PHx 2.1.3
Two solutions. Either run Jot uncached on an uncached page, or use a snippet to get Jot’s placeholders and output them:
$output = $modx->getPlaceholder("jot.html.comments");
return $output;
-
- 77 Posts
Great, this works - thank you!