PhoenixKit.Modules.Publishing.Web.Controller.Fallback (phoenix_kit v1.7.69)

Copy Markdown View Source

404 fallback handling for the publishing controller.

Implements a smart fallback chain that attempts to redirect users to related content when the requested resource is not found:

  • Posts in other languages
  • Other posts on the same date
  • Group listing page

Summary

Functions

Fallback for timestamp mode posts - comprehensive fallback chain

Tries to find any available published language version of the post.

Tries each language for timestamp mode until finding a published version.

Handles 404 not found responses with smart fallback.

Functions

fallback_timestamp_to_other_language(group_slug, date, time, requested_language)

Fallback for timestamp mode posts - comprehensive fallback chain:

  1. Try other languages for the exact date/time
  2. If time doesn't exist, try other times on the same date
  3. If date has no posts, fall back to group listing

find_any_available_language_version(group_slug, post_slug, requested_language)

Tries to find any available published language version of the post.

Priority:

  1. Check for published versions in the SAME language first (across all versions)
  2. Then try other languages
  3. Falls back to group listing if no published versions exist

Note: fetch_post now handles finding the latest published version automatically, so we can just use base URLs here (no version-specific URLs needed)

find_first_published_timestamp_version(group_slug, date, time, languages)

Tries each language for timestamp mode until finding a published version.

handle_not_found(conn, reason)

Handles 404 not found responses with smart fallback.