Example: create a new page (sTool = "page")

A page in TypeStack is composed of several pieces:

  • A structure item (cms_structure).
  • A translation (cms_structure_translations).
  • A link to a substance (cms_substances).
  • A page record (cms_pages).
  • A page grid (cms_page_grid) that selects slides.
  • Content blocks (cms_content) positioned inside those slides.

This example creates a new page under structure_id = 7 (for example the homepage), using template 1, and writes an initial HTML block into the first slide of that template:

{ "aOperations": [ { "sTool": "page", "sMode": "create-page", "aArgs": { "sTitle": "TypeStack Magic – Agent documentation", "sSubtitle": "How the Agent reads, writes and builds pages", "sDescription": "Internal documentation page generated by the Agent.", "sCase": "typestack-magic-agent-docs", "iParentStructureID": 7, "iTemplateID": 1, "sContentHTML": "

TypeStack Magic

\n

This page was created by AgentToolPage.

" } } ] }

Internally, the Agent will:

  1. Create a new cms_structure row under iParentStructureID.
    Note: structure_parent_id is never 0 for children; the root is typically 1. The structure_substance_id is resolved from the current session.
  2. Create a cms_structure_translations row for the current language, with:
    • translation_title = sTitle
    • translation_case = sCase (URL slug)
    • translation_subtitle, translation_description as provided
  3. Create a cms_pages row for the current substance:
    • page_structure_id = new structure ID
    • page_template_id = iTemplateID
    • page_status_id = 1 (active)
  4. Clone the first slide from cms_template_grid into cms_page_grid:
    • Looks up the first active row for grid_template_id = iTemplateID, ordered by grid_order, grid_id.
    • Inserts a cms_page_grid entry for that grid_slide_id.
  5. Insert a cms_content row for that slide (optional, only if sContentHTML is provided):
    • content_page_id = new page ID
    • content_slide_id = selected slide
    • content_structure_id = new structure ID
    • content_html = sContentHTML
    • content_language_id = current language

    Positioning fields such as content_position_x, content_position_y, content_size_x, content_size_y, content_order control where the content lives inside the slide grid. The helper inserts a minimal block; more advanced layouts can be added later.

The JSON response includes the new iStructureID, iPageID, iContentID and a detailed aDebug trail that logs every step.

In the current step, sMode = "create-page" focuses on simple page creation. Read/update/delete modes will be added on top of the same AgentToolPage class.