WordPress.org

Ready to get started?Download WordPress

Forums

CMS Tree Page View
Menu order mixed up on moving a page (1 post)

  1. Robert Kayser
    Member
    Posted 1 year ago #

    Repositioning a page by drag and drop sometimes doesn't work properly. The page moves one too far up or down or cannot be moved at all.

    The reason for this is a bug in cms_tpv_move_page. For the "before" case, the menu_order ist not being calculated correctly. Here's what I did to make it work:


    //replace this (line 1574 in version 1.2.4):
    $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET menu_order = menu_order+1 WHERE post_parent = %d", $post_ref_node->post_parent ) );

    //with this:
    $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET menu_order = menu_order+2 WHERE post_parent = %d AND menu_order > %d OR id = %d", $post_ref_node->post_parent, $post_ref_node->menu_order, $post_ref_node->ID ) );

    //delete this (line 1578):
    $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET menu_order = menu_order+1 WHERE menu_order >= %d", $post_ref_node->menu_order+1) );

    //and in the post_to_save array replace this:
    "menu_order" => $post_ref_node->menu_order

    //with this (just adding "+1"):
    "menu_order" => $post_ref_node->menu_order+1

    This is almost similar to the "after" case, which is working fine already.

    http://wordpress.org/extend/plugins/cms-tree-page-view/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic