From d591200df8f179a80ed2dca2a51889dab41d400e Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Fri, 3 Apr 2026 18:42:45 +0200 Subject: [PATCH] fix(cms): storefront renders sections for landing pages + fix nav URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two critical fixes for POC site rendering: 1. Storefront content page route now selects template based on page.template field: 'full' → landing-full.html (section-based), 'modern'/'minimal' → their respective templates. Default stays content-page.html (plain HTML). Previously always used content-page which ignores page.sections JSON. 2. Storefront base_url uses store.subdomain (lowercase, hyphens) instead of store.store_code (uppercase, underscores) for URL building. Nav links now point to correct paths that the store context middleware can resolve. Co-Authored-By: Claude Opus 4.6 (1M context) --- app/modules/cms/routes/pages/storefront.py | 10 +++++++++- app/modules/core/utils/page_context.py | 6 ++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/modules/cms/routes/pages/storefront.py b/app/modules/cms/routes/pages/storefront.py index 92dbd1cf..3561b74a 100644 --- a/app/modules/cms/routes/pages/storefront.py +++ b/app/modules/cms/routes/pages/storefront.py @@ -109,8 +109,16 @@ async def generic_content_page( context = get_storefront_context(request, db=db, page=page) context["page_content"] = page_content + # Select template based on page.template field + template_map = { + "full": "cms/storefront/landing-full.html", + "modern": "cms/storefront/landing-modern.html", + "minimal": "cms/storefront/landing-minimal.html", + } + template_name = template_map.get(page.template, "cms/storefront/content-page.html") + return templates.TemplateResponse( - "cms/storefront/content-page.html", + template_name, context, ) diff --git a/app/modules/core/utils/page_context.py b/app/modules/core/utils/page_context.py index 2f4ad986..a05b857f 100644 --- a/app/modules/core/utils/page_context.py +++ b/app/modules/core/utils/page_context.py @@ -384,15 +384,17 @@ def get_storefront_context( if access_method == "path" and store: platform = getattr(request.state, "platform", None) platform_original_path = getattr(request.state, "platform_original_path", None) + # Use subdomain (lowercase, hyphens) for URL routing — store_code is for internal use + store_slug = store.subdomain or store.store_code if platform and platform_original_path and platform_original_path.startswith("/platforms/"): - base_url = f"/platforms/{platform.code}/storefront/{store.store_code}/" + base_url = f"/platforms/{platform.code}/storefront/{store_slug}/" else: full_prefix = ( store_context.get("full_prefix", "/storefront/") if store_context else "/storefront/" ) - base_url = f"{full_prefix}{store.store_code}/" + base_url = f"{full_prefix}{store_slug}/" # Read subscription info set by StorefrontAccessMiddleware subscription = getattr(request.state, "subscription", None)