Enter the editor
studio-editor.php loads the shared editor-page.php implementation. The editor requires a signed-in user. It selects a site using both the site ID and session user ID, so a URL parameter alone must not grant access to another user’s site.
Save structured and rendered content
save_site.php receives HTML, CSS and JSON in a POST request. It removes GrapesJS internal attributes, rebases template asset URLs and works with storage helpers. JSON represents editor state while HTML/CSS represent the rendered website; keep both consistent.
Publishing changes site state
The save endpoint distinguishes saving and publishing actions. Publishing updates sites.is_published and saved content after ownership checks. Page navigation and template asset helpers participate in the process. Inspect the exact action branch before changing behavior; do not test publishing on a real customer site.
Syntax in practice
A focused learning example. Read the referenced source file for its full application context.
$stmt = $pdo->prepare('SELECT * FROM sites WHERE id = ? AND user_id = ?');
$stmt->execute([$site_id, $user_id]);
$site = $stmt->fetch();
if (!$site) {
// Stop: the current user does not have access to this site.
}Try it yourself
Trace a test site’s ID and user ID from the editor request to the save ownership check.
Work on a development copy, then explain what changed and how you verified it.
Project file map
Find these paths in your local WebsHigher checkout. Source paths are references, not public downloads of application code.
studio-editor.phpeditor-page.phpsave_site.phpincludes/storage_helper.phpincludes/page-navigation.php