Skip to content

fix(cms): homepage latest-pages block should respect the category page order, not date #535

@jbourdin

Description

@jbourdin

Bug

The latestPages homepage block currently sorts pages by createdAt DESC. Admins can reorder pages within a category via drag-and-drop (Page.position), but the homepage block ignores that ordering.

Root cause

PageRepository::findPublishedByCategory() (src/Repository/PageRepository.php:73):

->orderBy('p.createdAt', 'DESC');

The admin list (createAdminListQueryBuilder, lines 170-171) already does it correctly:

->orderBy('p.position', 'ASC')
->addOrderBy('p.createdAt', 'DESC');

Fix

Replace the orderBy in findPublishedByCategory to mirror the admin query: position ASC, then createdAt DESC as tiebreaker.

Files

  • src/Repository/PageRepository.php:73

Verification

  1. In a category, drag-reorder the pages so the order differs from the creation order.
  2. Reload the homepage; the latestPages block must render in the admin-defined order.
  3. Update the existing repository test (or add one) covering findPublishedByCategory ordering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions