From e98fb8f797776b5c0bab7f86dbb574b9af19a2c3 Mon Sep 17 00:00:00 2001 From: Aaron Dalton Date: Sat, 16 Mar 2019 17:16:13 +0000 Subject: [PATCH] Latest Articles list fixed. --- CHANGELOG.md | 3 ++- templates/partials/sidebar.html.twig | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b51d87d..fad2035 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,12 @@ ## 03/16/2019 1. [](#new) - * Categories can now have landing pages like authors do (optional), thanks again to @awrog. + * Categories can now have landing pages like authors do (optional), thanks to @awrog. * Duth translation added, thanks to @awrog. 1. [](#bugfix) * Comments section hidden if `comments` plugin not present. + * The "Latest Articles" list now finds all articles regardless of folder structure. # v2.0.1 ## 12/11/2018 diff --git a/templates/partials/sidebar.html.twig b/templates/partials/sidebar.html.twig index ef12226..373cecf 100644 --- a/templates/partials/sidebar.html.twig +++ b/templates/partials/sidebar.html.twig @@ -1,3 +1,14 @@ +{% set homeroute = '/home' %} +{% if grav.theme.config.params.articleroot is defined %} + {% set homeroute = grav.theme.config.params.articleroot %} +{% endif %} +{% if grav.theme.config.params.articles.root is defined %} + {% set homeroute = grav.theme.config.params.articles.root %} +{% endif %} + +{% set options = { items: {'@page.descendants': homeroute}, 'order': {'by': 'date', 'dir': 'desc'}} %} +{% set my_collection = page.collection(options) %} + {% set catlist = taxonomy.taxonomy["category"]|keys %} {% set blist = [] %} {% if grav.theme.config.params.articles.blacklist is defined %} @@ -11,14 +22,6 @@ {% set catlist = tmplst %} {% endif %} -{% set homeroute = '/home' %} -{% if grav.theme.config.params.articleroot is defined %} - {% set homeroute = grav.theme.config.params.articleroot %} -{% endif %} -{% if grav.theme.config.params.articles.root is defined %} - {% set homeroute = grav.theme.config.params.articles.root %} -{% endif %} - {% if grav.theme.config.params.sidebar.show.categories %}

{{ 'CATEGORIES'|t }}

@@ -75,9 +78,8 @@ {% if grav.theme.config.params.sidebar.show.latest %}

{{ 'LATEST_ARTICLES'|t }}

- {% set articles = page.find(homeroute).children.order('date', 'desc') %} {% set tmplst = [] %} - {% for page in articles %} + {% for page in my_collection %} {% set blisted = false %} {% for bcat in blist %} {% if bcat in page.taxonomy["category"] or (page.header.published is defined and not page.header.published) %}