Skip to main content

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 isVisible flag;
  • custom attributes: any fields you define, in attributeValues;
  • content in several languages.

Page types​

A page's type is one of:

Typetype valueExample Use
Common Pagecommon_pageAbout, Contact, Terms
Catalog Pagecatalog_pageCatalog categories
External Pageexternal_pageLinks to external URLs
Error Pageerror_page404 / 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​

MethodWhen to UseExample
By URLUser visits specific pagegetPageByUrl("about")
By IDInternal referencesgetPageById(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 the GET /api/content/pages/{url}/config endpoint, which now answers 404, and the IPageConfig type is gone with it. Read the same values from page.config in 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​

MethodWhat It DoesWhen to Use
getPages()Get all pagesBuild sitemap, list all pages
getRootPages()Get all top-level (root) pagesBuild top-level navigation
getChildPagesByParentUrl()Get child pages by parent URLWalk a section's subtree
getBlocksByPageUrl()Get PositionBlock objects for a page by URLRender page content blocks
getPageById()Get a single page by IDInternal references
getPageByUrl()Get a single page by URLRender a page on a route
searchPage()Quick search for pagesSearch pages by title
getPagesByVectorSearch()Semantic (vector) search for pagesMatch pages by meaning, not by keywords