When the headerViewModel is being build I want to detect if the startpage is loading. Any pointers on how to do that?
Litium version: 7
When the headerViewModel is being build I want to detect if the startpage is loading. Any pointers on how to do that?
Litium version: 7
I don’t know if it’s the correct Litium way to do this, but an easy way would be to resolve the HttpContext in the controller.
You can try to use _requestModelAccessor.RequestModel.CurrentPageModel.Page.ParentPageSystemId == Guid.Empty
in the Litium.Accelerator.Builders.Framework.HeaderViewModelBuilder.Build
-method.
I had that exakt line earlier and it didn’t work when I tried to navigate to a category page. The ParentPageSystemId
was still an empty Guid. In the build-method
you refer I changed to look at the RawUrl
of the request and compare it to the startpageUrl. Got it working for now
For all product catalog pages the start page will be the “active” page.
To not compare the url you can also inject the Litium.Web.Routing.RouteRequestInfoAccessor
and make the check like this
var onStartPage = _requestModelAccessor.RequestModel.CurrentPageModel.Page.ParentPageSystemId == Guid.Empty
&& !(_routeRequestInfoAccessor.RouteRequestInfo.Data is Litium.Web.Products.Routing.ProductPageData);