Custom Fields
Re-Envisioned
Support MB Relationships Drag and drop order reset without consent

This topic contains 21 replies, has 4 voices, and was last updated by  Anh Tran 2 months ago.

  • Creator
    Topic
  • #11679
    Resolved
    Clayton Collie
    Participant

    I used the drag and drop functionality to arrange the relationships in the exact order I needed them to show on the front-end. Now they have reverted back to where when they were added to the database. Where is the order stored in the db? Why would it revert back? Frontend and backend match up so I know that there is not a sort order on the frontend.

Viewing 10 replies - 1 through 10 (of 21 total)
  • Author
    Replies
  • #11688

    Anh Tran
    Keymaster

    Hi Juanita,

    Did you save the post after reordering the relationships? The plugin relationship values in the exact order they’re set in the backend. In the frontend, they’re sorted by the ID columns from mb_relationships table. This is the query looks like in the plugin’s code:

    View post on imgur.com

    #11695

    Clayton Collie
    Participant

    Did some testing and found that when I arrange the relationships on a bi-directional relationship, you cannot have a specific sort order on both sides of the relationship.

    In my use case, I have an attorney related to a practice area. I want a specific order on the practice area page and then another order of relationships when viewing the attorney biography.

    It might be good to add to_order and from_order database column so that you can arrange relationships independently of each other. You could keep the default order to be ID unless filtered to use the from_order or to_order column.

    #11703

    Anh Tran
    Keymaster

    You’re right about the order for bi-directional relationships. I’ll add a task on that.

    Thanks!

    #11714

    Clayton Collie
    Participant

    The other thing I noticed is that if you change the post title, then resave, that post gets pushed to the bottom of the related pages list.

    #11732

    Doug
    Participant

    Juanita/Anh – I just noticed this unwanted behavior as well. You don’t even need to change the post title. Just go to one of the posts in the admin, click update without making any changes, and it will get pushed to the end of the related posts list (both in WP admin, and in the rendered post set).

    Bummer, because I constantly need to go back to the post where I’ve specified the relationship, and drag them back to the original order.

    #11816

    Clayton Collie
    Participant

    Anh, any update on either of these two issues?

    1. Add column in database table to store sort order on both sides of the relationship.
    2. Do not change sort order on save. I think Doug hit it on the head here. I have attorneys related to a practice area. Both sides of the relationship have a custom sort order that is thrown off by any of the posts being re-saved. If an attorney changes any content on his bio then saves the cpt entry, his name is pushed to the bottom of the list on the practice area page.

    FYI, Clayton is my real name. Juanita is the office manager that bought/signed up this account when we purchased the bundle.

    Also, if you give me a little hint about where to look for #2, I can trouble shoot on my end to speed it along.

    #12153

    Anh Tran
    Keymaster

    Hey Clayton and Doug,

    We’ve just a fix for this problem on Github. Can you please test it?

    We follow your instruction by adding 2 columns order_from and order_to to track the order of each side. So far so good for now. Please take a look.

    #12552

    Clayton Collie
    Participant

    Went to test this and I cannot save a relationship value.

    I installed a clean version of 4.9.8 and also 5.0 to test on with the same results. The database structure was created properly and happy to see the extra columns. Here are the steps I took to test.

    1. Installed Metabox from wp.org repo.
    2. Installed MB Relationships from Github repo.
    3. Create plugin to instantiate relationship field. Copied code from documentation.
    4. Created 1 page and 1 post.
    5. Set relationship with Post Object select field.
    6. Select Publish.

    On save, the relationship fields get cleared out. Reset back to a single empty value.

    Am I missing something on my setup? Have you tested on a fresh install?

    #12573

    Vee Jay
    Participant

    I have the same problem with the “reset” of the field.

    I also get this error when enabling debug mode:

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE to=150 AND type=’post2conf’ ORDER BY order_to’ at line 1]
    SELECT from FROM WHERE to=150 AND type=’post2conf’ ORDER BY order_to

    #12607

    Doug
    Participant

    Finally had a chance to test master from github (as well as v1.4.1 downloaded directly from metabox.io, which seems to be identical to what’s on github). This version won’t load or save any existing relationship data.

    For anyone having major issues with 1.4.1, rolling back to version 1.4.0 at least works again for me, though still with the re-ordering issue this thread originally reported.

    I have debugging turned on, and with v1.4.1 installed, I see this at the top at the top of every wp-admin page, which seems to prevent loading or saving any relationship data (username and server name obscured from my paste):

    Notice: Undefined property: RWMB_Relationships_Table_Storage::$db in /home/username/servername.com/wp-content/plugins/mb-relationships-master/inc/database/class-mb-relationships-storage-handler.php on line 61

    Notice: Trying to get property of non-object in /home/username/servername.com/wp-content/plugins/mb-relationships-master/inc/database/class-mb-relationships-storage-handler.php on line 61

    Warning: Cannot modify header information – headers already sent by (output started at /home/username/servername.com/wp-content/plugins/mb-relationships-master/inc/database/class-mb-relationships-storage-handler.php:61) in /home/username/servername.com/wp-admin/includes/misc.php on line 1126

Viewing 10 replies - 1 through 10 (of 21 total)

You must be logged in to reply to this topic.