PhoenixKit.Modules.Publishing.PublishingCategory (PhoenixKitPublishing v0.6.0)

Copy Markdown View Source

Hierarchical, per-group category (WordPress-parity taxonomy). Backed by core migration V159 (phoenix_kit_publishing_categories).

  • The tree is a nullable parent_uuid self-FK; the DB lifts children to the root when a parent is deleted (ON DELETE SET NULL). Same-group scope and cycle prevention are context-layer rules (Publishing.Categories), mirroring the V103 catalogue-categories and V116 entity-data conventions.
  • slug is unique per group, not globally — two groups can both have "news". It is intentionally not translated (single canonical URL segment), matching the group-slug rule.
  • name_i18n carries per-language display-name overrides keyed by language code (%{"et" => "Uudised"}); the primary-language name lives in name. Resolution is base-tolerant via translated_name/2.

Summary

Functions

Changeset for create/update. group_uuid is cast on create only (a category never moves between groups); the context layer validates the parent (same group, no cycles) before the DB sees it.

Create changeset — additionally casts and requires the owning group.

The category's display name for a language, base-tolerant the same way PublishingGroup.translated_name/2 is: exact code, then any stored code sharing the base, then the primary name.

Types

t()

@type t() :: %PhoenixKit.Modules.Publishing.PublishingCategory{
  __meta__: term(),
  description: String.t() | nil,
  group: term(),
  group_uuid: Ecto.UUID.t() | nil,
  inserted_at: DateTime.t() | nil,
  name: String.t() | nil,
  name_i18n: map(),
  parent: term(),
  parent_uuid: Ecto.UUID.t() | nil,
  position: integer(),
  slug: String.t() | nil,
  updated_at: DateTime.t() | nil,
  uuid: Ecto.UUID.t() | nil
}

Functions

changeset(category, attrs)

Changeset for create/update. group_uuid is cast on create only (a category never moves between groups); the context layer validates the parent (same group, no cycles) before the DB sees it.

create_changeset(category, attrs)

Create changeset — additionally casts and requires the owning group.

translated_name(category, language)

The category's display name for a language, base-tolerant the same way PublishingGroup.translated_name/2 is: exact code, then any stored code sharing the base, then the primary name.