Skip to content
SprecherEast
Issue 1496

feat: Related events picked by an editor on a post, with a join field listing a post on each event

Back to our plan
Open
enhancementfrontendcmspriority: mediumready

Problem

An editor can't say which events a post is about, and an event can't show the posts written about it. Today only post-to-post links exist (relatedPosts).

Proposed fix

Native Payload, no custom code:

  • Add a relatedEvents relationship field (hasMany, to events) on posts, in the same Meta tab and sidebar style as relatedPosts, filtered to published events.
  • Add a join field on events (for example relatedPosts) with collection: 'posts' and on: 'relatedEvents', so each event lists the posts that link to it. A join field is virtual: nothing extra is stored on the event.
  • Show both on the page through the existing mappers and block, hand-picked first. This stays the base and the override for the automatic matching in the sibling issue.
  • Saving a post refreshes the pages of the events it links, and the other way round (existing revalidate hooks).

Finding to verify while building (the docs don't say it plainly): the join field is documented for relationship and upload fields on the other collection, and polymorphic joins; confirm it works with a hasMany relationship and with draft and published posts (the join should list only published posts to visitors).

Existing work compared

Searched open and closed issues and the code for related posts, related events, join field and relatedPosts.

  • relatedPosts on posts (src/modules/news/cms/posts.ts) is post-to-post only; this adds the events direction, in the same style.
  • #1484 and the epic: automatic matching builds on top of this; it does not replace it.
  • #677: page layout of related lists; this supplies two of its inputs.
  • Not a duplicate of any open issue.

Native-first ladder

  1. Native: Payload relationship field plus join field. Join field docs, opens in a new tab: virtual, "works in all database adapters" (we use SQLite), options collection, on, where, maxDepth, defaultLimit, defaultSort. This does the job.
  2. Official plugins: not needed.
  3. Open source: not needed.
  4. Our code: only the mapping from the field values into the existing related block's props (in the module's data/ mappers and ui/), and tests.

Acceptance criteria

  • Not done: An editor can pick events on a post; the picker lists only published events.
  • Not done: An event shows the published posts that link to it, with no editor step on the event.
  • Not done: A hand-picked event or post shows on the page first; nothing is shown when there are none.
  • Not done: Saving or unpublishing either side refreshes the other side's page.
  • Not done: The join works with hasMany, drafts and SQLite, shown by a test.
  • Not done: The migration, the generated types, the knowledge notes and docs/reference/ are updated in the same pull request.

Files likely touched

src/modules/news/cms/posts.ts, src/modules/events/cms/events.ts, the two modules' data/ mappers, queries, ui/ and README.md, revalidate hooks, src/migrations/, src/payload-types.ts, docs/reference/ (generated).

Must not touch

Automatic matching, embeddings, intelligence/, agent access rules.

Open questions

None.

Area and priority

Areas: cms, frontend. Priority: medium. Effort: Medium.


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab