fix(cms): storefront renders sections for landing pages + fix nav URLs
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) <noreply@anthropic.com>
This commit is contained in:
@@ -109,8 +109,16 @@ async def generic_content_page(
|
|||||||
context = get_storefront_context(request, db=db, page=page)
|
context = get_storefront_context(request, db=db, page=page)
|
||||||
context["page_content"] = page_content
|
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(
|
return templates.TemplateResponse(
|
||||||
"cms/storefront/content-page.html",
|
template_name,
|
||||||
context,
|
context,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -384,15 +384,17 @@ def get_storefront_context(
|
|||||||
if access_method == "path" and store:
|
if access_method == "path" and store:
|
||||||
platform = getattr(request.state, "platform", None)
|
platform = getattr(request.state, "platform", None)
|
||||||
platform_original_path = getattr(request.state, "platform_original_path", 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/"):
|
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:
|
else:
|
||||||
full_prefix = (
|
full_prefix = (
|
||||||
store_context.get("full_prefix", "/storefront/")
|
store_context.get("full_prefix", "/storefront/")
|
||||||
if store_context
|
if store_context
|
||||||
else "/storefront/"
|
else "/storefront/"
|
||||||
)
|
)
|
||||||
base_url = f"{full_prefix}{store.store_code}/"
|
base_url = f"{full_prefix}{store_slug}/"
|
||||||
|
|
||||||
# Read subscription info set by StorefrontAccessMiddleware
|
# Read subscription info set by StorefrontAccessMiddleware
|
||||||
subscription = getattr(request.state, "subscription", None)
|
subscription = getattr(request.state, "subscription", None)
|
||||||
|
|||||||
Reference in New Issue
Block a user