Skip to content

PullRelatedField is not pulling the content in any order #21929

@erickgonzalez

Description

@erickgonzalez

Describe the bug
The $dotcontent.pullRelatedField() method is not returning the related content in the same order that the related content was added when the sort parameter is not used.

To Reproduce
Steps to reproduce the behavior:

  1. Create 4 contents of the Content-Type Blog Comments (c1, c2, c3, c4).
  2. Create a blog and relate the 4 comments.
  3. Reorder the comments (c4,c1,c2,c3)
  4. Create a Code Snippet Widget with the code:
#set($id = "ID OF THE CREATED BLOG")
#set($comments = $dotcontent.pullRelatedField($id,"Blog.blogComment", "+languageId:1", 3, ""))
<h3>Comments</h3>
#foreach($comment in $comments)
<div>
Blog comment: $comment.title
</div>
#end
  1. Create a page and add the created widget.
  2. Check the order of the comments, should be the same as the one of the content (c4, c1, c2). But is showing (c4,c2,c3).

Expected behavior
When no sort parameter is specified, the $dotcontent.pullRelatedField() method should return the related content in the same order that the related content was added.

Screenshots
ORDER BY MOD DATE
OrderByModDate
ORDER AT THE CONTENT
OrderContentRelationships
ORDER SHOWING IN THE PAGE
OrderPageRender

Additional context
Customer Ticket: https://dotcms.zendesk.com/agent/tickets/106898
Reproducible in demo (22.03)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions