The problem is that PHx eats placeholders. They still exist in the $modx->placeholder array, though, so you can use a snippet to return $modx->getPlaceholder(’placeholder-name’) in place of the usual placeholders.
Personally, while I think PHx is great for internal snippet use, modifying placeholders within a snippet’s chunk tpl, I never use the plugin. There is nothing at all that PHx can do that you can’t do just as quickly and easily and more reliably with a snippet, without bogging MODx down with the plugin parsing on top of the document parser (and incidentally eating all those poor innocent placeholder tags).
For example, if I want to do something only if a logged-in manager user is viewing the page, I can use a snippet like this:
<?php
$breakfast = '<script type="text/javascript">
$("#one,#two,#three,#four").dragsort({ dragSelector: "li", dragEnd: saveOrder, dragBetween: false, placeHolderTemplate: "<li></li>" });
function saveOrder() {
var data = new Array();
$("div#sortable li").each(function(i, elm) { data[i] = $(elm).attr("id"); });
$.post("[~18~]", { "ids[]": data });
};
</script>';
$lunch = '<script type="text/javascript">
$("#one,#two").dragsort({ dragSelector: "li", dragEnd: saveOrder, dragBetween: false, placeHolderTemplate: "<li></li>" });
function saveOrder() {
var data = new Array();
$("div#sortable li").each(function(i, elm) { data[i] = $(elm).attr("id"); });
$.post("[~18~]", { "ids[]": data });
};
</script>';
$dinner = '<script type="text/javascript">
$("#one, #two, #three, #four, #five").dragsort({ dragSelector: "h3", dragEnd: saveOrder, dragBetween: false });
function saveOrder() {
var data = new Array();
$("div#sortable li").each(function(i, elm) { data[i] = $(elm).attr("id"); });
$.post("[~18~]", { "ids[]": data });
};
</script>';
$kids = '<script type="text/javascript">
$("#one").dragsort({ dragSelector: "li", dragEnd: saveOrder, dragBetween: false, placeHolderTemplate: "<li></li>" });
function saveOrder() {
var data = new Array();
$("div#sortable li").each(function(i, elm) { data[i] = $(elm).attr("id"); });
$.post("[~18~]", { "ids[]": data });
};
</script>';
if($_SESSION['mgrValidated']) {
$modx->regClientStartupScript('assets/js/jquery.dragsort-0.3.10.min.js');
$doc = $modx->documentIdentifier;
switch ($doc) {
case 5:
$modx->regClientScript($breakfast);
break;
case 4:
$modx->regClientScript($lunch);
break;
case 3:
$modx->regClientScript($dinner);
break;
case 6:
$modx->regClientScript($kids);
break;
default:
return;
}
}
return;
?>
It establishes the javascript necessary for implementing a drag-and-drop sorting feature to a Jot/Notes list. It makes allowances for which menu we want to be working with; they have a varying number of categories. Then it loads the appropriate javascript for the page in question if the user is a logged-in manager user.