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.

5.8 KB
Raw Blame
@model KnowledgebaseHomePageModel
@inject IPageHeadBuilder pagebuilder
@{
    Layout = "_TwoColumns";
}

@*rendering breadcrumb section*@

@section Breadcrumb
{
    <ol class="breadcrumb">
        <li class="breadcrumb-item">
            <a href="@Url.RouteUrl("Knowledgebase")" title="@Loc["Knowledgebase"]">@Loc["Knowledgebase"]</a>
        </li>

        @foreach (var cat in Model.CategoryBreadcrumb)
        {
            <li class="breadcrumb-item">
                <a href="@Url.RouteUrl("KnowledgebaseCategory", new { cat.SeName })" title="@cat.Name">@cat.Name</a>
            </li>
        }
    </ol>
}

@section left {
    @await Component.InvokeAsync("KnowledgebaseCategories", Model)
}

<div class="page">
    <h1 class="h2 generalTitle">
        @if (string.IsNullOrEmpty(Model.CurrentCategoryName))
        {
            if (string.IsNullOrEmpty(Model.SearchKeyword))
            {
                @Loc["Knowledgebase"]
            }
            else
            {
                <label class="mb-0 error-label red">
                    @Loc["Knowledgebase.ResultsFor"] <i>@Model.SearchKeyword</i>
                </label>
            }
        }
        else
        {
            @Model.CurrentCategoryName
        }
    </h1>

    @if (string.IsNullOrEmpty(Model.CurrentCategoryId))
    {
        pagebuilder.AddTitleParts(Loc["Title.Knowledgebase"]);
        <form method="get" id="small-search-box-form" asp-action="ItemsByKeyword" asp-controller="knowledgebase" novalidate="novalidate">
            <div class="input-group">
                <span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>
                <input type="text" class="form-control search-box-text ui-autocomplete-input" id="small-searchterms" autocomplete="off" name="keyword" placeholder="@Loc["Knowledgebase.SearchPlaceholder"]">

                <span class="input-group-append">
                    <button type="submit" class="btn btn-info d-flex float-sm-end">
                        <span class="visually-hidden">Search store</span>
                        <i class="b-icon bi bi-search mx-1" aria-hidden="true"></i>
                        <span class="d-none d-lg-block">@Loc["Knowledgebase.Search"]</span>
                    </button>
                </span>
            </div>
        </form>

        @await Component.InvokeAsync("PageBlock", new { systemName = "KnowledgebaseHomePage" })
        @await Component.InvokeAsync("KnowledgebaseHomepageArticles", Model)
    }
    else
    {
        @inject SeoSettings seoSettings
        {
            Layout = "_TwoColumns";
            pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.CurrentCategoryMetaTitle) ? Model.CurrentCategoryMetaTitle : Model.CurrentCategoryName);
            pagebuilder.AddMetaDescriptionParts(Model.CurrentCategoryMetaDescription);
            pagebuilder.AddMetaKeywordParts(Model.CurrentCategoryMetaKeywords);
            var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
            if (canonicalUrlsEnabled)
            {
            var categoryUrl = Url.RouteUrl("ArticlesByCategory", new { SeName = Model.CurrentCategorySeName
        },Url.ActionContext.HttpContext.Request.Scheme);
        pagebuilder.AddCanonicalUrlParts(categoryUrl);
        }
        }

        @Html.Raw(Model.CurrentCategoryDescription)

        @if (Model.Items.Any())
        {
            <div class="list-group">
                @foreach (var item in Model.Items)
                {
                    if (item.IsArticle)
                    {
                        <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseArticle", new { item.SeName })">
                            @if (!string.IsNullOrEmpty(Model.SearchKeyword) && !string.IsNullOrEmpty(item.FormattedBreadcrumbs))
                            {
                                @item.FormattedBreadcrumbs
                            }
                            else
                            {
                                @item.Name
                            }
                        </a>
                    }
                    else
                    {
                        <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseCategory", new { item.SeName })">
                            @if (!string.IsNullOrEmpty(Model.SearchKeyword) && !string.IsNullOrEmpty(item.FormattedBreadcrumbs))
                            {
                                @item.FormattedBreadcrumbs
                            }
                            else
                            {
                                @item.Name
                            }
                        </a>
                    }
                }
            </div>
        }
        else
        {
            <div class="error-label alert alert-danger">@Loc["Knowledgebase.Notfound"]</div>
            <form method="get" id="small-search-box-form" asp-action="ItemsByKeyword" asp-controller="knowledgebase" novalidate="novalidate">
                <div class="input-group mt-3">
                    <span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>
                    <input type="text" class="form-control search-box-text ui-autocomplete-input" id="small-searchterms" autocomplete="off" name="keyword" placeholder="@Loc["Knowledgebase.SearchPlaceholder"]">

                    <span class="input-group-append">
                        <button type="submit" class="btn btn-info d-flex float-sm-end">
                            <span class="visually-hidden">Search store</span>
                            <i class="b-icon bi bi-search mx-1" aria-hidden="true"></i>
                            <span class="d-none d-lg-block">@Loc["Knowledgebase.Search"]</span>
                        </button>
                    </span>
                </div>
            </form>
        }
    }
</div>