Skip to Content

Get by ID & Slug Pages

An entity’s detail/show page can be reached three ways: a unified page that figures out ID-vs-slug for you, and two explicit pages that force one or the other. All three live under /[locale]/[entity]/, and each has a matching edit page.


The routes

Show pages render DetailShowContainer; edit pages render EditEntityContainer. The three ID/slug shapes are identical on both sides:

Show routeEdit routeResolves by
/[entity]/[id]/[entity]/[id]/editID or slug (auto)
/[entity]/id/[id]/[entity]/id/[id]/editID (explicit)
/[entity]/slug/[slug]/[entity]/slug/[slug]/editslug (explicit)

The pathname handed to getPageConfig mirrors the URL and ends in /show or /edit, e.g. /{locale}/{entity}/id/{id}/show or /{locale}/{entity}/slug/{slug}/edit.

Every page follows the same shape: build the pathname, hand it to getPageConfig with the user’s roles and the page type (SHOW or EDIT), and render the matching container (DetailShowContainer with showProps, EditEntityContainer with editProps). If the lookup comes back not-authorized, not-found, or empty, the page renders the shared NotFoundPage.

const pathname = `/${params.locale}/${params.entity}/${params.id}/show`; const { data, notFoundEntity, notAuthorized } = await getPageConfig( pathname, getUserRoles(), "SHOW", ); if (notAuthorized || notFoundEntity || !data) return <NotFoundPage />; return <DetailShowContainer {...data.showProps} />;

The unified /[id] page

The bare /[entity]/[id] page accepts either identifier and picks the lookup from the segment itself: if it’s numeric, the entity is fetched by ID; otherwise it’s treated as a slug. So both of these land on the same page and resolve the same record:

/en/dataanalysis-datacollectors/39 → by ID /en/dataanalysis-datacollectors/ProductStockLevelCheckSum → by slug

The explicit /id/[id] and /slug/[slug] routes skip the guesswork and always use the stated lookup — handy for links that must be unambiguous, or when a slug happens to look like a number.

Slug lookups only work when the entity implements Sluggable on the backend (it exposes a slug). See Entity Interfaces for the interface flags and the backend implementation.


When the ID / slug doesn’t exist

If neither an ID nor a slug matches, getPageConfig returns notFoundEntity and the route renders NotFoundPage:

/en/dataanalysis-datacollectors/Pro321 → not found

Usage

Detail/show page resolved by numeric ID

The same detail/show page resolved by slug

Not-found page for an unknown ID or slug


Tracking issue: #1161 (Get by Slug Page and Get by ID pages) .

Last updated on