Saving relationship order

35 views
Skip to first unread message

Arjen

unread,
Sep 6, 2017, 9:57:17 AM9/6/17
to dotCMS User Group
Hi,

Is it just me or does the admin portal not save the order of related items?
I can add items to a relationship and then drag them in a certain order, but next time I go back it will have the same order as before my changes again (I think it reverts to the modification date of the related items).

Later on, in my code, I use the ContentletRelationships getRelationshipsRecords() method to loop over these related items which works fine, but sticks to the order then the admin portal reverts to, not the order I saved them in.

Any ideas how I can fix this?
I tried different browsers, and different machine, but to no avail.
dotcms 4.1.1

Thanks
Arjen

Henry Versemann

unread,
Sep 6, 2017, 10:03:29 AM9/6/17
to dot...@googlegroups.com

Thanks.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c05ca129-f34a-496b-87ce-3b4e57e150be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nathan Keiter

unread,
Sep 6, 2017, 10:07:57 AM9/6/17
to dot...@googlegroups.com

It’s not just you, there are a lot of similar bugs in the 4.x UI.  I was hoping the latest patch would fix them. Sounds like 4.1.1 did not.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of Arjen
Sent: Wednesday, September 06, 2017 9:57 AM
To: dotCMS User Group
Subject: [dotcms] Saving relationship order

 

Hi,

--

Arjen

unread,
Sep 6, 2017, 10:19:01 AM9/6/17
to dotCMS User Group
Thanks for confirming Nathan, at least I can stop scratching my head.
You wouldn't happen to have a different method of setting the order, do you?

By the way, I think it's the creation date it sorts on, not the modification date as I thought earlier.

Thanks
Arjen

Nathan Keiter

unread,
Sep 6, 2017, 10:23:32 AM9/6/17
to dot...@googlegroups.com

If possible, write your code in a way that‘s not order dependent?

 

Or fetch the related content and manually re-order it before using it?

 

It’s more of an annoyance for us, we don’t have anything dependent on the order right now.

Will Ezell

unread,
Sep 6, 2017, 10:24:24 AM9/6/17
to dot...@googlegroups.com
The UI should set the order of the related content objects.  Can you reproduce on the demo site?

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--



3059 Grand Avenue
Suite 410-B
Miami FL 33133
Main: 
305-900-2001 | Direct: 978.294.9429

   

Arjen

unread,
Sep 6, 2017, 10:37:15 AM9/6/17
to dotCMS User Group
Interesting Will, the demo site does appear to work ok but mine consistently doesn't.
I don't see anything interesting in the logs either but I'll see what happens with relationships of non-custom objects.

Thanks
Arjen

Jason Tesser

unread,
Sep 6, 2017, 10:41:08 AM9/6/17
to dotCMS User Group
do you have any plugins that use hooks or might effect how content saves?

Nathan Keiter

unread,
Sep 6, 2017, 10:42:44 AM9/6/17
to dot...@googlegroups.com

Well that’s good news then.  I have yet to upgrade our DEV site to the latest 4.x patch level.  I’ll compare that to all the bug reports, support tickets, and GIThub issues, I’ve created and see what was fixed when I do.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of Arjen


Sent: Wednesday, September 06, 2017 10:37 AM
To: dotCMS User Group

Subject: Re: [dotcms] Saving relationship order

 

Interesting Will, the demo site does appear to work ok but mine consistently doesn't.

Arjen

unread,
Sep 6, 2017, 10:51:00 AM9/6/17
to dotCMS User Group
@LORDs_diakonos - No, it's pretty much a default system with a few custom objects and one plugin (my own) that creates a bespoke REST API.


@Will Ezel - I think I can get mine to save the order as long as the relationship is many-to-many. As soon as I set it to one-to-many it stops saving.
Ive only been able to test it briefly, but would you be able to confirm this?

Thanks
Arjen

Nathan Keiter

unread,
Sep 6, 2017, 11:12:18 AM9/6/17
to dot...@googlegroups.com

@Arjen Can you replicate the “many-to-many vs. other” in demo?

 

If so, a screencast of the demo site is often the fastest way to get results.

Arjen

unread,
Sep 6, 2017, 11:25:03 AM9/6/17
to dotCMS User Group
Hi Nathan,

Thanks, I was already testing that but yes it does appear to be replicateable in the demo system.

I just added a new object "Object A" with one text property.
I then added a one-to-many relationship between a landing page and object a (LandingPage-Objecta).
I then tried to re-order them by dragging but that doesn't work, just like on my system.

I'll try to make a screen recording but I'm not very good at that so may take a while.

Arjen

Nathan Keiter

unread,
Sep 6, 2017, 11:35:19 AM9/6/17
to dot...@googlegroups.com

Screencastify plugin for Google Chrome makes it very easy. (And it’s free. Paid account allows longer videos.)

 

It also automatically links to your Google docs.

 

Tip: You might want to move the newly created video to a new folder location in your Google docs before sharing it.  Also, a low res video is immediately available, but there’s a delay of a few minutes before the video is available in high res.  I believe this is due to Google’s video content censoring algorithm. I wait to share it with support until the high res version is being served by Google.

Arjen

unread,
Sep 6, 2017, 12:07:41 PM9/6/17
to dotCMS User Group
Thanks for the tip, that was a lot easier then it used to be.

Quite frustrating though, but when I did my recording and created a new test object "Object B" this did all work as it's supposed to and ordering saved fine, so I'm starting to doubt what causes it.
So I tested again with the previous object I had created (Object A) and that still had the original problem so I made a recording of that showing that it doesn't save the order of the relationship.


I'm not sure what causes it now, but on my test machine setting the relationship to many did at fix it once.
Hopefully this makes sense to someone else as it doesn't to me...

Arjen

Nathan Keiter

unread,
Sep 6, 2017, 12:16:42 PM9/6/17
to dot...@googlegroups.com

No problem. It’s a life saver (and time saver.) If a picture is worth a thousand words, a video is worth a million words.

Arjen

unread,
Sep 7, 2017, 8:59:56 AM9/7/17
to dotCMS User Group
Hi all,

I've been troubleshooting this most of the day but have yet to find a fix that works reliably, so if anyone knows a way to set the order some other manual way then please let me know.
At this stage I don't mind if the admin portal displays it incorrectly as long as I can control the order somehow...

Thanks again
Arjen

Arjen

unread,
Sep 11, 2017, 4:22:35 PM9/11/17
to dotCMS User Group
It's taken some time but I found the cause of this behaviour as well as a workaround so in case someone else has the same issue please try this.

It turns out that only objects that have been created using the "Content -> Search -> Add New Content" option in the admin portal can be ordered if they are added to a relationship after.
Objects created using "Object -> Relationships -> Relate -> Relate New Content" visually look identical but can only change order once. Any time after that the re-ordering will just not save.

Now, I had the problem that I already had quite a bit of content that had been created using the "Relate" option and didn't want to re-order, but it turns out that exporting all objects of type X and then re-importing the exact same files does something to these objects that make them behave normally again, as if they had been created from the content search page to begin with.

I hope that saves someone else some time.

Arjen

oscar....@dotcms.com

unread,
Sep 12, 2017, 5:10:06 PM9/12/17
to dotCMS User Group
hi Arjen

Thanks so much to take the time to help reproduce this one. I just tested with one branch of latest source code and I can't reproduce your case, even when creating the content via "Relate New Content."
1. What version are you using? 
2. Can you reproduce in demo.dotcms.com?
3. I tested with Blog - Comments relationship. Can you reproduce in your env with the same contents as me?

Thanks.

Arjen

unread,
Sep 13, 2017, 7:37:55 AM9/13/17
to dotCMS User Group
Hi Oscar,

It looks like my reply earlier this morning hasn't been published so here it is once more.

But I recorded a video of the issue on your demo system which you can download here: https://drive.google.com/file/d/0B5NmEothR9UGWklZZmJyQmZTTW8/view
Where I refer to "externally created objects" I mean objects that I have created using the "Add New Content" option, whereas  "internally created objects" have been created using the "Relate New Content" option within the relationships.

Here are some timecodes to explain what's happening etc, but please have a look at the bit from 3:10 to 3:28 as that shows that the objects' order hasn't been saved.
0:00 - 1:30 Creation of 2 custom test objects: Object A and Object B. There's a many-to-many relationship between A and B.
1:30 - 3:28 Demonstration of the 2 'internally' created Object B items that do not save their order.
3:28 - 5:36 Demonstration of the 2 'externally' created Object B items that do save their order.

I hope that helps.

Arjen

ad...@weclick.media

unread,
Sep 13, 2017, 9:29:45 AM9/13/17
to dotCMS User Group
Hi Oscar,

Thanks for testing this as well.

I have just created a video showing the exact problem on your demo system, please have a look at https://drive.google.com/file/d/0B5NmEothR9UGWklZZmJyQmZTTW8/view
When I refer to 'internally created objects' I mean that they have been created using the 'Relate new content' option, whereas 'externally created objects' have been created using the 'Add New Content' option.

Here are some timecode to split it up as it's a rather long video.
0:00 - 1:30 Creation of 2 custom test objects: Object A and Object B. There's a many-to-many relationship between A and B.
1:30 - 3:28 Demonstration of the 2 'internally' created Object B items that do not save their order. Both at 3:11 and at 3:28 the order is B-1, B-2 despite having changed it! 
3:28 - 5:36 Demonstration of the 2 'externally' created Object B items that do save their order.

I hope that clarifies the issue.

Thanks
Arjen


On Tuesday, September 12, 2017 at 10:10:06 PM UTC+1, oscar....@dotcms.com wrote:
Reply all
Reply to author
Forward
0 new messages