We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9549
    • 93 Posts
    I’m doing a "sort menu" kind of thing which allow the user to move their documents up/down in the tree.
    NewsManager function "Move to top" alter the menuindex value to now(). Pretty primitive in my opionion!

    My code looks like this

      if ($menuid == $resource[$x]['id'] && $menuvalue != "") {
      if ($sort == "up") {
            $sortid = $menuvalue -1;
      }
      if ($sort == "down" ) {
            $sortid = $menuvalue +1;
      }
        $flds = array(
                  'menuindex' => $sortid,
                             );
        $modx->db->update($flds, $tbl, "id = $menuid");
        $modx->sendRedirect($modx->makeUrl($postid));
      }



    As you can see this function just adds or reduces the menuindex value, not taking anything else into consideration. That’s pretty primitive too, as nothing would happen if two links have the same value and so on.. A possible solution were to not allow duplicate menuindex values or something. But I don’t know enough of PHP do that..

    Anyone up for a challenge? wink
      • 9549
      • 93 Posts
      If somebody interested, I’m willing to pay to get this done. Just a script which sort order the menu by it’s menuindex value.