Hierarchy Logic
Pyxis CMS uses a Tree Structure to organize content. Each page can have an optional “parent,” which directly influences the URL structure and site navigation.
Relationship Model
Section titled “Relationship Model”In the database, the hierarchy is based on the parent_id column, which points to the id of another page within the same table.
- Root Page:
parent_idisNULL. The URL is simply/{slug}. - Child Page:
parent_idpoints to a parent. The URL is/{parent_slug}/{child_slug}.
Dynamic Path Calculation (Full URL)
Section titled “Dynamic Path Calculation (Full URL)”The full path of a page is not hardcoded in a single column. Instead, it is computed dynamically by the Eloquent model (Laravel) during every API request.
Recursion Mechanism
Section titled “Recursion Mechanism”The model traverses up the tree until it hits a page without a parent (Root), concatenating the slugs into a single path.
// Logical example in the Page model:protected function fullUrl(): Attribute{ return Attribute::make( get: function() { // If page have parent, get his full url if ($this->parent_id && $this->parent) { return rtrim($this->parent->full_url, '/') . '/' . $this->slug; }
// If page is main return / return '/' . $this->slug; }, );}SEO & Management Benefits
Section titled “SEO & Management Benefits”- No Redundancy: Changing a parent's slug automatically "moves" all its children to the new URL from the API's perspective.
- Breadcrumbs: This structure allows the API to easily return an array of ancestors for any given page, enabling Next.js to render breadcrumb navigation.
- Integrity: The API validation system (see Slug Resolution) ensures that a subpage is never rendered if the user skips any segment of the parent path.
Roadmap
Section titled “Roadmap”A dedicated /api/navigation endpoint is planned. It will return the entire page tree (titles and URLs only) to automatically build navigation menus in Next.js.