Pages
Fetch pages and mobile app screens with their attributes, blocks and templates.
More information about the module's user interface https://doc.oneentry.cloud/docs/category/pages (opens in a new tab)
The Pages module retrieves pages for websites and screens for mobile apps, with all their content: title, HTML or plain content, visibility and custom attributes. You author pages in the OneEntry admin panel and fetch them at runtime, so content changes go live without a redeploy.
Quickstart
Initialize the module from defineOneEntry:
const { } = defineOneEntry( , { });
Fetch a single page by its URL (marker) and read its fields:
// Fetch the "about" page in English.
const page = await Pages.getPageByUrl("about", "en_US");
if ('statusCode' in page) throw new Error(page.message);
console.log(page.id, page.localizeInfos.title);
console.log("Visible:", page.isVisible);
// Custom fields you defined live in attributeValues.
console.log(page.attributeValues);
Most read methods take an identifier (url or id) and a langCode. The method table below lists them all.
Pages
A page is a content entity: a page of your website (e.g. /about, /contact) or a screen of your mobile app (e.g. Profile or Settings).
Each page has:
- content: the title and HTML or plain content in
localizeInfos; pageUrl: the page marker used for routing and lookups;- the
isVisibleflag; - custom attributes: any fields you define, in
attributeValues; - content in several languages.
Page types
A page's type is one of:
| Type | type value | Example Use |
|---|---|---|
| Common Page | common_page | About, Contact, Terms |
| Catalog Page | catalog_page | Catalog categories |
| External Page | external_page | Links to external URLs |
| Error Page | error_page | 404 / Not Found page |
These are the values of PageType. The GeneralTypes module lists every entity type in the project, including block and form types.
Page hierarchy
Pages form a tree through parentId. Top-level pages have parentId: null:
Company
├─ About Us
├─ Team
└─ Careers
Products
├─ Product Category 1
│ ├─ Product A
│ └─ Product B
└─ Product Category 2
Fetch the root pages with getRootPages() and walk down with getChildPagesByParentUrl(). The same two methods build navigation; for managed navigation structures, use the Menus module.
Identifying pages
| Method | When to Use | Example |
|---|---|---|
| By URL | User visits specific page | getPageByUrl("about") |
| By ID | Internal references | getPageById(123) |
pageUrl is the page marker (e.g. "about"). It is user-facing and stable across environments. id is the numeric identifier, used for internal references.
pageUrl is not a Next.js route path: pass the OneEntry marker (e.g. "about"), not /en/about, and never hardcode a framework route path as the URL.
Page object
The key fields of a page:
{
"id": 9,
"parentId": 8,
"pageUrl": "blog1",
"depth": 1,
"localizeInfos": {
"title": "Blog 1",
"menuTitle": "Blog 1",
"htmlContent": "",
"plainContent": ""
},
"isVisible": true,
"blocks": [],
"type": "common_page",
"templateIdentifier": null,
"attributeSetIdentifier": null,
"attributeValues": {},
"isSync": false
}
Display settings
Catalog pages carry their output settings on the page entity itself, in the optional config field (Record<string, number>), for example rowsPerPage and productsPerRow. The field comes with page lists (getPages(), getRootPages(), getChildPagesByParentUrl()); getPageByUrl() and getPageById() don't return it:
const pages = await Pages.getPages();
if ('statusCode' in pages) throw new Error(pages.message);
const page = pages.find((p) => p.pageUrl === "catalog");
const rows = page?.config?.rowsPerPage;
const perRow = page?.config?.productsPerRow;
Migration: the separate
getConfigPageByUrl()method was removed. The API dropped theGET /api/content/pages/{url}/configendpoint, which now answers404, and theIPageConfigtype is gone with it. Read the same values frompage.configin the page lists.
Localization
To get the same page in another language, request it with a different langCode.
Custom attributes
Add fields to pages with AttributesSets: a blog post's author, date and tags, a landing page's hero image, SEO meta and so on. Read them from page.attributeValues rather than assuming built-in fields. SEO isn't a built-in field: model the meta title, description and other tags as custom attributes. See the AttributesSets Module.
Visibility
The isVisible flag controls which pages users see. Filter for isVisible: true in production.
Cache pages to reduce API calls, and handle a missing page (404).
Methods
| Method | What It Does | When to Use |
|---|---|---|
| getPages() | Get all pages | Build sitemap, list all pages |
| getRootPages() | Get all top-level (root) pages | Build top-level navigation |
| getChildPagesByParentUrl() | Get child pages by parent URL | Walk a section's subtree |
| getBlocksByPageUrl() | Get PositionBlock objects for a page by URL | Render page content blocks |
| getPageById() | Get a single page by ID | Internal references |
| getPageByUrl() | Get a single page by URL | Render a page on a route |
| searchPage() | Quick search for pages | Search pages by title |
| getPagesByVectorSearch() | Semantic (vector) search for pages | Match pages by meaning, not by keywords |
Related
- Products Module: manage e-commerce products
- Blocks Module: reusable content blocks for pages
- AttributesSets Module: custom fields for pages
- Menus Module: navigation menu management
- GeneralTypes Module: page types