Expand description
Categories & taxonomies — hierarchical categorization, built the same way pages are: real migration-tracked models, not a JSON blob or a config file.
model::Category(cms_category) is the abstract base row — a materialized-path tree with typed columns (name, description, featured image, thumbnail, parent). Every vocabulary shares it.model::Taxonomy(cms_taxonomy) is the vocabulary registry, mirroringcms_page_type: one row per vocabulary, synced from theTaxonomyHandlerinventory at seed (upsert_taxonomy). The DB rows are the runtime source of truth (taxonomies).assign::PageCategory(cms_page_category) files pages under categories.
A custom vocabulary is registered in code exactly like a custom
page type: implement TaxonomyHandler + register_taxonomy!(T).
Extra typed fields (a country’s flag + ISO code) live in the handler’s
own per-type extension table (unique category_id FK) — the
error_pages/page-type extension pattern. The built-in category
vocabulary ships with only the base columns.
The tables are created by a migration (0005_categories.json,
generated via cargo run --example gen_migration), not runtime
ensure_table — so they are tracked exactly like cms_page.
Re-exports§
pub use assign::PageCategory;pub use model::Category;pub use model::CategoryError;pub use model::CategoryNode;pub use model::NewCategory;pub use model::Taxonomy;pub use model::DEFAULT_MAX_DEPTH;
Modules§
- assign
- Page ↔ category assignments — the
cms_page_categoryM2M, mirroringcrate::page_snippet_m2m/crate::page_tag. A page can be filed under many categories across many vocabularies; the join row denormalizestaxonomy_idso the editor can replace one vocabulary’s assignments without touching the others. - model
- Category models — real, migration-tracked tables (not a JSON blob). Two models:
Structs§
- Category
Taxonomy - The built-in hierarchical
categoryvocabulary shipped with every tenant. Base columns only — name, description, featured image, thumbnail, parent. The flatpage_tagstory stays the tags vocabulary. - Taxonomy
Handler Registration - Inventory registration for a
TaxonomyHandler(mirrorsPageTypeHandlerRegistration). Populated byregister_taxonomy!.
Traits§
- Taxonomy
Handler - A code-registered vocabulary. Mirrors
PageTypeHandler: process-global, zero-arg constructible via theregister_taxonomy!factory. The definition is synced into acms_taxonomyrow at seed; the optional extension hooks back a custom typed-field table.
Functions§
- find_
handler - The code handler for
slug(for the extension hooks). - find_
taxonomy - The
cms_taxonomyrow forslug, if seeded. - registered_
handlers - Every code-registered vocabulary handler in the binary.
- taxonomies
- Every registered vocabulary, from the DB (the runtime source of truth, seeded from handlers), ordered by slug.
- upsert_
taxonomy - Sync a
cms_taxonomyrow from a registered handler — find-or-create keyed on the natural keyslug, mirroringupsert_page_type(seed.rs). Called per-tenant at seed.