The CreateStructureOnly helper in AgentToolPage is a minimal building block used by the TypeStack Agent. Instead of creating a full page (structure, translation, page, grid, content), this helper focuses on just two tables:
cms_structurecms_structure_translationsThis is useful for debugging and for simple scenarios where we only need a new menu / structure item with a title and slug. If this minimal insert works reliably, the same logic can be used as a stable foundation for full page creation.
The helper is exposed through the Agent as a dedicated operation: sTool = "page" with sMode = "create-structure-only". It can be called from the Magic prompt using JSON with aOperations.
The operation is triggered with:
sTool: "page"sMode: "create-structure-only"aArgs: arguments for the structure, translation, and cache contextExample JSON payload for the Magic prompt:
{ "aOperations": [ { "sTool": "page", "sMode": "create-structure-only", "aArgs": { "iInstanceID": 70, "sTitle": "Gerards Testpagina – alleen structure", "sSubtitle": "", "sDescription": "Test vanuit CreateStructureOnly", "iParentStructureID": 1 } } ]
} iInstanceID (int, strongly recommended)env tool. sTitle (string, optional but recommended)translation_title. If omitted, a generic "New Agent Structure" is used. sSubtitle (string, optional)translation_subtitle. sDescription (string, optional)translation_description. sCase (string, optional)translation_case (slug). If omitted, the system auto-generates a slug via GenerateSlug(). iParentStructureID (int, optional)1, which is typically the root menu item. Additional context is resolved from the active CMS session:
iSubstanceID – the active substance (frontend site variant)iLanguageID – the current language (defaults to 1) If iInstanceID or iSubstanceID cannot be resolved, the helper aborts and returns an error.
cms_structureA new structure row is added with the following values:
structure_parent_id = iParentStructureIDstructure_substance_id = iSubstanceIDstructure_type_id = 2structure_route_id = 0structure_link_url = NULLstructure_link_type_id = 1structure_icon, structure_css, structure_class = NULLstructure_order = 9999structure_status_id = 1structure_hidden = 0cms_structure_translationsA language-specific translation row is added:
translation_structure_id = new structure_idtranslation_title = sTitletranslation_case = sCase or auto-generated slugtranslation_subtitle = sSubtitletranslation_description = sDescriptiontranslation_language_id = resolved iLanguageIDtranslation_structure_status_id = 1 After creating a structure and translation, the Agent will clear the frontend website cache for the correct instance. This mirrors the internal behaviour of TypeStack's CMS_Page::SavePage().
The Agent calls:
\Cache::ClearWebsiteCache($iInstanceID); Without this step, the page will exist in the database but the router will not recognise the slug until the CMS saves the page manually.
The helper returns structured debug information for analysis.
{ "bSuccess": true, "sTool": "page", "sMode": "create-structure-only", "sMessage": "Structure + translation created successfully (CreateStructureOnly).", "iStructureID": 123, "iTranslationID": 456, "aArgs": { "iInstanceID": 70, "sTitle": "Gerards Testpagina – alleen structure", "iParentStructureID": 1 }, "aDebug": [ "Resolved instance = 70, substance = 1, language = 1", "Insert cms_structure OK", "Insert cms_structure_translations OK", "Website cache cleared for instance 70" ]
}iInstanceIDIf the wrong instance ID is provided, the page will appear in the CMS but not on the frontend, because the wrong router cache is cleared.
Occurs when the Agent is invoked outside an active CMS session.
When pasting JSON, ensure the Magic prompt does not HTML-encode quotes or line breaks.
Once CreateStructureOnly works reliably, the same arguments (especially iInstanceID) power the full CreatePage() operation.
Full page creation includes:
If a page exists in the CMS but not the frontend, it is always cache-related and never a database error.
The CreatePage helper in AgentToolPage performs the full automated creation of a frontend page inside a TypeStack instance. Unlike CreateStructureOnly, which only inserts a structure and a translation, the full page workflow includes:
This workflow is the equivalent of creating a page through the CMS interface, selecting a template, and saving the page — but fully automated, triggered by the Magic prompt.
The operation is triggered by:
sTool: "page"sMode: "create-page"aArgs: arguments defining the new pageExample JSON payload:
{ "aOperations": [ { "sTool": "page", "sMode": "create-page", "aArgs": { "iInstanceID": 70, "sTitle": "Gerards Fietsenwinkel", "sSubtitle": "De beste fietsen in Vriezenveen", "sDescription": "Service, onderhoud en advies", "sCase": "gerards-fietsenwinkel", "sContentHTML": "<h1>Welkom bij Gerards Fietsenwinkel</h1>", "iParentStructureID": 1, "iTemplateID": 1 } } ]
}iInstanceID (int, strongly recommended)env tool. sTitle (string)sSubtitle (string, optional)cms_structure_translations. sDescription (string, optional)sCase (string, optional)sTitle. sContentHTML (string, optional)cms_content is inserted. iParentStructureID (int, optional)1. iTemplateID (int, required)cms_page_grid. cms_structureA new structure node is created, identical to creating a menu item manually in the CMS. Values include:
structure_parent_id = iParentStructureIDstructure_substance_id = resolved substancestructure_type_id = 2structure_order = 9999structure_hidden = 0 The new structure_id is returned as iStructureID.
cms_structure_translationsA new translation row is created for the chosen language:
translation_structure_id = iStructureIDtranslation_title, translation_casetranslation_subtitle, translation_descriptiontranslation_language_idcms_pagesA page container is created and linked to the chosen template.
page_structure_id = iStructureIDpage_substance_id = resolved substancepage_template_id = iTemplateID The returned page_id is used when generating slides.
cms_page_grid The template may define one or multiple slides (header, content, footer, …). For each enabled slide (status ID = 1), a corresponding cms_page_grid entry is generated.
Example: Template 1 may define:
All slides are created automatically.
cms_content (optional) If sContentHTML is provided:
cms_content row is created containing the HTML If no HTML is provided, no cms_content is inserted.
After creating the page, slides and optional content, the Agent clears the website cache for the correct instance:
\Cache::ClearWebsiteCache($iInstanceID); This mirrors CMS_Page::SavePage() behaviour and ensures:
Without this step, the database would contain the new page but the frontend router would not recognise it until a manual SavePage or a backend cache clear.
The Agent returns a detailed structured response.
{ "bSuccess": true, "sMessage": "Page created successfully.", "iStructureID": 42, "iTranslationID": 42, "iPageID": 37, "iGridID": 2168, "iContentID": 270, "aDebug": [ "Context: iInstanceID=70, iSubstanceID=1, iLanguageID=1", "Insert cms_structure OK", "Insert cms_structure_translations OK", "Insert cms_pages OK", "Slides generated: 35, 36, 22", "Content inserted into slide 36", "Website cache cleared for instance 70" ]
}iInstanceID The page will appear in the CMS but not on the live website if the wrong instance is used. Always ensure iInstanceID matches the current application.
If a template has no active slides (status ID ≠ 1), the page will be created without layout. The debug output will explicitly list “No template grid row found”.
When pasting large JSON payloads, ensure the browser does not insert HTML entities like ".
iInstanceID explicitly.env tool to verify instance/substance context.sContentHTML only for the main content slide.CreateStructureOnly first when debugging. With these guidelines, CreatePage() behaves exactly like a CMS-created page — but fully automated.