Is there still really no way to sort related pages?

Vic Carter asked on November 30, 2018 15:52

Simple question. I see posts about this going back to kentico 8. Has no sorting mechanism been added to the portal engine?

That seems kind of odd to me considering the related pages webpart allows for a sort order...

Any help with this would be greatly appreciated.

Recent Answers


Brenden Kehren answered on November 30, 2018 16:11

There is no way. You can see the comment from David Komarack on the submitted on the Ideas Forum back in 2015.

"The classical “Relationships” functionality will not provide sorting due to the two-side nature."

0 votesVote for this answer Mark as a Correct answer

Vic Carter answered on November 30, 2018 16:20

Thanks Brenden, as always you are quite helpful. This seems odd as there is a field for it in the database and the relationship table knows both sides of the connection. I guess I will just have to use the document tree.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on November 30, 2018 16:27

The way relationships are setup is a simple LeftNodeID, RightNodeID, RelationshipNameID columns. Now as I look at the database, it looks as if there is a RelationshipOrder column too but I don't beleive it's hooked up. So you could do some modification for it I guess but I'm not sure how well it would work. You have the ability to display pages based on the left or right node id and you only have one order set. So if you're looking at the left node id and ordering by the RelationshipOrder, this works. When you go to get the same pages based off of the right node id, the order will be the same as if it were on the left node. Not really ideal, you'd need a left and right order by field.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on December 3, 2018 14:04

The named relationships cannot be ordered. But you can use the Pages field on your page type, which creates an ad-hoc relationship and this one can be ordered. Either by using the three dots or, by using drag and drop handle.

1 votesVote for this answer Mark as a Correct answer

Volodymyr Rets answered on March 8, 2019 19:38

Juraj Ondrus, how can I use CombineWithDefaultCulture when i use Pages field?

Kentico calls TreeNode.GetRelatedDocuments() which does not work with CombineWithDefaultCulture, but it works with DocumentQueryBase.InRelationWith().

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on March 11, 2019 13:33

Hi,
If you will take a look at the CMS_Relationship table, which stores the relations, you will see it is working with NodeIDs and these are not culture specific. Please see this documentation to see where the culture specific data are stored.
So, once you get the related page NodeID, you will need to check in the CMS_Document table whether it exists in given culture, if not, find the default culture record in the CMS_Document table for given NodeID.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.