That shouldn’t be difficult; I’ve done something along those lines with Jot (I call the modded version Notes) that has an extra field for this, and an added bit of Javascript to allow drag-and-drop ordering.
The snippet I use to insert the required JQuery functionality only if a manager user is logged in:
<?php
$js = '<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');
$modx->regClientScript($js);
}
return;
?>
And the AJAX processor - I use a snippet in a resource, in the above code it’s resource #18, for this:
<?php
// AJAX processor for sorting Notes items
if ($_POST) {
$ids = $_POST['ids'];
//print_r($ids);
foreach ($ids as $order => $id) {
$modx->db->update("position = $order", $modx->getFullTableName("notes_content"), "id = $id");
}
}
?>