Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

6.1 KB
Raw Blame
@{
    Layout = "_Layout";

    //current category ID
    var currentCategoryId = "";
    if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.OrdinalIgnoreCase) &&
        Url.ActionContext.RouteData.Values["action"].ToString().Equals("category", StringComparison.OrdinalIgnoreCase))
    {
        currentCategoryId = Url.ActionContext.RouteData.Values["categoryId"].ToString();
    }


    //current collection ID
    var currentCollectionId = "";
    if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.OrdinalIgnoreCase) &&
        Url.ActionContext.RouteData.Values["action"].ToString().Equals("collection", StringComparison.OrdinalIgnoreCase))
    {
        currentCollectionId = Url.ActionContext.RouteData.Values["collectionId"].ToString();
    }

    //current brand ID
    var currentBrandId = "";
    if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.OrdinalIgnoreCase) &&
        Url.ActionContext.RouteData.Values["action"].ToString().Equals("brand", StringComparison.OrdinalIgnoreCase))
    {
        currentBrandId = Url.ActionContext.RouteData.Values["brandId"].ToString();
    }

    //current product ID
    var currentProductId = "";
    if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("product", StringComparison.OrdinalIgnoreCase) &&
        Url.ActionContext.RouteData.Values["action"].ToString().Equals("productdetails", StringComparison.OrdinalIgnoreCase))
    {
        currentProductId = Url.ActionContext.RouteData.Values["productId"].ToString();
    }
}
@if (IsSectionDefined("Breadcrumb"))
{
    @section Breadcrumb {
        @await RenderSectionAsync("Breadcrumb")
    }
}

@section meta {
    @await RenderSectionAsync("meta", false)
}

@section head {
    @await RenderSectionAsync("head", false)
}

@if (!string.IsNullOrEmpty(currentCategoryId))
{
    @await Component.InvokeAsync("Widget", new { widgetZone = "home_page_category", additionalData = Model.Id })
}
@if (!string.IsNullOrEmpty(currentCollectionId))
{
    @await Component.InvokeAsync("Widget", new { widgetZone = "home_page_collection", additionalData = Model.Id })
}
@if (!string.IsNullOrEmpty(currentBrandId))
{
    @await Component.InvokeAsync("Widget", new { widgetZone = "home_page_brand", additionalData = Model.Id })
}
<div id="TwoColumns" class="row custom-container mt-3">
    <div class="d-lg-none d-block" id="mobile-filters-toggle">
        <div class="col-12">
            <button id="sidebar-mobile-button" class="btn btn-outline-info" data-bs-toggle="offcanvas" data-bs-target="#sidebar-mobile" aria-controls="sidebar-mobile">
                <i class="b-icon bi bi-layout-sidebar-inset" aria-hidden="true"></i> @Loc["catalog.selectors.fiters"]
            </button>
        </div>
        <div class="offcanvas offcanvas-start b-sidebar shadow" tabindex="-1" id="sidebar-mobile" aria-labelledby="sidebar-mobile-label">
                <div class="b-sidebar-header">
                    <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
                    <strong class="ms-2" id="sidebar-mobile-label"></strong>
                </div>
                <div class="b-sidebar-body">
        </div>
            </div>
    </div>
    @*The filters render here as a bare <template v-if>, so this column needs an
        island of its own: an uncompiled <template> renders nothing at all - the
        catalog filters silently vanished rather than showing raw markup.*@
    @*
        The declaration is conditional because this column is shared: only the
        catalog layouts define a `filters` section, and only that section reads the
        `catalog` view-model. Declaring it unconditionally would ask every
        two-column page for a view-model that is not there, which logs a warning
        per page. No declaration is a valid state - the island then renders against
        the shell alone.
    *@
    <div class="col-lg-3 col-md-12 generalLeftSide order-1"
         vue-island="@(IsSectionDefined("filters") ? "catalog" : "")">
        @if (IsSectionDefined("left"))
        {
            @await RenderSectionAsync("left")
        }
        else
        {
            if (IsSectionDefined("filters"))
            {
                @await RenderSectionAsync("filters")
            }

            @await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_before" })
            @await Component.InvokeAsync("CategoryNavigation", new { currentCategoryId, currentProductId })
            @await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_after_category_navigation" })
            @await Component.InvokeAsync("CollectionNavigation", new { currentCollectionId })
            @await Component.InvokeAsync("VendorNavigation")
            @await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_after" })
        }
    </div>
    <div class="col-lg-9 col-md-12 generalSideRight order-2">
        @await Component.InvokeAsync("Widget", new { widgetZone = "main_column_before" })
        @RenderBody()
        @await Component.InvokeAsync("Widget", new { widgetZone = "main_column_after" })
    </div>
</div>
<script type="application/json" data-grand-vm="twoColumnsSidebar">@Json.Serialize(new {
                                                                      elements = new {
                                                                          sidebarSelector = ".generalLeftSide",
                                                                          desktopHostId = "TwoColumns",
                                                                          mobileHostSelector = "#sidebar-mobile .b-sidebar-body",
                                                                          toggleId = "mobile-filters-toggle",
                                                                          categoryNavigationId = "block-category-navigation"
                                                                      }
                                                                  })</script>