Skip to main content

Introduction

Manage website pages and mobile app screens with dynamic content.

🎯 What does this module do?

The Pages module lets you create, retrieve, and manage pages (for websites) or screens (for mobile apps) with all their content - text, images, SEO settings, and custom attributes.

Think of it as your content management system - instead of hardcoding pages, you manage them in OneEntry and fetch them dynamically in your app.

📖 Simple Explanation

Imagine you're building a website with these pages:

  • 🏠 Home page - main landing page
  • 📄 About Us - company information
  • 📞 Contact - contact form page
  • 📝 Blog posts - multiple article pages
  • FAQ - help center

Instead of creating each page manually in your code, you:

  • ✅ Create pages in OneEntry admin panel (with content, images, SEO)
  • ✅ Fetch pages dynamically using this module
  • ✅ Update content without redeploying your app
  • ✅ Manage page structure, URLs, and metadata in one place

Real-world example:

Without Pages Module (hardcoded):
- Edit homepage → Change code → Test → Deploy → Wait ❌
- 10 pages = 10 code files to manage ❌
- SEO changes = code changes ❌

With Pages Module (dynamic):
- Edit homepage → Update in OneEntry admin → Live instantly ✅
- 100 pages = fetch dynamically from API ✅
- SEO changes = update in admin panel ✅

✨ Key Concepts

What is a Page?

A page is a content entity that represents:

  • Web: A page on your website (e.g., /about, /contact)
  • Mobile: A screen in your app (e.g., Profile Screen, Settings Screen)

Each page contains:

  • Content - Text, images, videos
  • URL - Page address (e.g., /about-us)
  • SEO - Meta title, description, keywords
  • Custom attributes - Any additional fields you define
  • Status - Published, draft, archived
  • Localization - Multi-language support

Page Types

OneEntry supports different page types:

TypeDescriptionExample Use
Normal PageStandard static pageAbout, Contact, Terms
Error Page404, 500 error pagesNot Found page
System PageSpecial pagesPrivacy Policy, Cookies
Template PageReusable page structureBlog post template

Page Hierarchy

Pages can be organized in a tree structure:

📁 Company
├─ About Us
├─ Team
└─ Careers

📁 Products
├─ Product Category 1
│ ├─ Product A
│ └─ Product B
└─ Product Category 2

Why this matters: You can fetch all pages in a section or build navigation menus automatically.

📋 What You Need to Know

1. Three Ways to Identify Pages

MethodWhen to UseExample
By URLUser visits specific page/about-us, /contact
By IDInternal references123, 456

Best practice: Use markers in code (they don't change), use URLs for routing.

2. Page Structure

Every page has these key fields:

{
id: 10,
parentId: null,
pageUrl: "catalog",
depth: 0,
localizeInfos: {
title: "Catalog",
menuTitle: "Catalog",
htmlContent: "",
plainContent: "",
},
isVisible: true,
blocks: ["product_block", "test"],
type: "catalog_page",
templateIdentifier: "template",
attributeSetIdentifier: "page",
attributeValues: {
text: {
type: "string",
value: "catalog text",
position: 0,
additionalFields: [],
},
number: {
type: "integer",
value: 0,
position: 1,
additionalFields: []
},
real: {
type: "real",
value: "",
position: 2,
additionalFields: []
},
float: {
type: "float",
value: 0,
position: 3,
additionalFields: []
},
},
moduleFormConfigs: [],
isSync: true,
template: {
id: 4,
attributeSetIdentifier: null,
title: "Template",
generalTypeId: 4,
identifier: "template",
version: 0,
generalTypeName: "catalog_page",
attributeValues: {},
position: 1,
},
}

3. Localization (Multi-language)

Pages support multiple languages

Same page, different languages!

4. Custom Attributes

You can add any fields to pages using AttributesSets:

Examples:

  • Blog posts: author, publish date, tags, featured image
  • Product pages: price, SKU, gallery, specifications
  • Landing pages: hero image, CTA buttons, testimonials

Learn more: See AttributesSets Module

📊 Quick Reference Table - Common Methods

MethodWhat It DoesWhen to Use
getPages()Get all pages (paginated)Build sitemap, list all pages
getRootPages()Get all Root pages (paginated)
getChildPagesByParentUrl()Get all Child pages by ParentUrl (paginated)
getPageById()Get page by IDInternal references
getPageByUrl()Get page by URLRouting (user visits /about)
getPageByMarker()Get page by markerReference specific page in code
getQuickPages()Get pages with minimal dataFast navigation menus
getRelatedPages()Get related/child pagesBuild sub-menus, related articles

❓ Common Questions (FAQ)

Q: What's the difference between URL and Marker?

A:

  • URL (pageUrl) - The web address users see (e.g., /about-us, /contact)

    • Can change over time
    • Used for routing
    • User-friendly
  • Marker - Technical identifier in code (e.g., homepage, contact_page)

    • Never changes
    • Used in code references
    • Technical, not user-facing

💡 Important Notes

Page URLs and Routing

Best practice for routing:

✅ Good: Dynamic catch-all route Next.js example: pages/[...slug].js

Caching for Performance

Reduce API calls with caching

Preview Drafts

Show draft pages to admins only

🎓 Best Practices

Do's:

  • ✅ Use markers in code (not URLs - they can change)
  • ✅ Cache pages to reduce API calls
  • ✅ Handle 404 errors gracefully
  • ✅ Filter by statusId: 1 and isVisible: true for production
  • ✅ Use getQuickPages() for navigation menus
  • ✅ Add loading states in UI
  • ✅ Implement page caching strategy

Don'ts:

  • ❌ Hardcode page URLs in your code
  • ❌ Fetch all pages without pagination (performance!)
  • ❌ Ignore statusId - might show draft pages to users
  • ❌ Forget to handle language switching
  • ❌ Load full pages when you only need basic info
  • ❌ Skip error handling

More information about the module's user interface https://doc.oneentry.cloud/docs/category/pages

Definition of the Pages module


const { Pages } = defineOneEntry(
"your-project-url", {
"token": "your-app-token"
}
);