Order the Blog By Year Descending

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Just a small bit of script, it might be changed in later versions of Nopcommerce, I am running 3.4 for www.childrensbooks.ie/Blog

This change orders the blog menu by year descending. In all of the previous Nopcommerce versions the blog itself always puts the latest article on the top of the list, but the menu on the left hand side is ordered the opoosite direction.

Anyway a simple change navigate to the blog view folder , find the partial view BlogMonths.cshtml and make the following change in bold below, nice and simple !

@model IList<BlogPostYearModel>
@using Nop.Web.Models.Blogs;
@if (Model.Count > 0)
{
    <div class="block block-blog-archive">
        <div class="title">
            <strong>@T("Blog.Archive")</strong>
        </div>
        <div class="listbox">
            <ul class="list" id="blog-month-list">
                @foreach (var yearItem in Model.OrderByDescending(col=>col.Year))
                {
                    <li class="year"><strong>@(yearItem.Year)</strong>
                        <ul class="sublist" id="blog-year-@(yearItem.Year)">
                            @foreach (var monthItem in yearItem.Months)
7 years ago
To finish this off, month descending would be good as well, see second bold section below

@model IList<BlogPostYearModel>
@using Nop.Web.Models.Blogs;
@if (Model.Count > 0)
{
    <div class="block block-blog-archive">
        <div class="title">
            <strong>@T("Blog.Archive")</strong>
        </div>
        <div class="listbox">
            <ul class="list" id="blog-month-list">
                @foreach (var yearItem in Model.OrderByDescending(col=>col.Year))
                {
                    <li class="year"><strong>@(yearItem.Year)</strong>
                        <ul class="sublist" id="blog-year-@(yearItem.Year)">
                            @foreach (var monthItem in yearItem.Months.OrderByDescending(col=>col.Month))
                            {
7 years ago
Thanks! But it's already how it works in the latest version
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.