Custom Fields
Re-Envisioned › Support › MB Relationships › Drag and drop order reset without consent
- This topic has 21 replies, 4 voices, and was last updated 2 years, 2 months ago by
Anh Tran.
-
CreatorTopic
-
October 19, 2018 at 9:00 PM #11679
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.
-
CreatorTopic
-
AuthorReplies
-
October 20, 2018 at 8:53 AM #11688
Anh Tran
KeymasterHi 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 frommb_relationships
table. This is the query looks like in the plugin’s code:October 21, 2018 at 1:00 AM #11695Content Pilot
ParticipantDid 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.
October 22, 2018 at 4:58 PM #11703Anh Tran
KeymasterYou’re right about the order for bi-directional relationships. I’ll add a task on that.
Thanks!
October 23, 2018 at 3:10 AM #11714Content Pilot
ParticipantThe 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.
October 24, 2018 at 3:49 AM #11732Doug
ParticipantJuanita/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.
November 1, 2018 at 10:36 PM #11816Content Pilot
ParticipantAnh, any update on either of these two issues?
- Add column in database table to store sort order on both sides of the relationship.
- 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.
November 22, 2018 at 3:54 PM #12153Anh Tran
KeymasterHey 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
andorder_to
to track the order of each side. So far so good for now. Please take a look.December 8, 2018 at 3:28 AM #12552Content Pilot
ParticipantWent 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.
- Installed Metabox from wp.org repo.
- Installed MB Relationships from Github repo.
- Create plugin to instantiate relationship field. Copied code from documentation.
- Created 1 page and 1 post.
- Set relationship with Post Object select field.
- 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?
December 10, 2018 at 12:43 PM #12573Vee Jay
ParticipantI 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 ANDtype
=’post2conf’ ORDER BY order_to’ at line 1]
SELECTfrom
FROM WHEREto
=150 ANDtype
=’post2conf’ ORDER BY order_toDecember 12, 2018 at 2:05 AM #12607Doug
ParticipantFinally 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
-
AuthorReplies
- You must be logged in to reply to this topic.