List of "featured" articles

I added a “featured” taxonomy, then in each article’s .md file, I have:

taxonomy:
  featured: true

Is this right?

…Then what’s the recommended way of going through the list (sorting by date) in a partial template?

1 Like

Yah that would work fine. Then in your template you could display the featured articles with:

{% for featured in taxonomy.findTaxonomy({'featured':true}) %}
    <h1>{{ featured.title }}</h1>
    <p>{{ featured.content }}</p>
{% endfor %}
1 Like

Ok… And would it be possible, to do this without taxonomy? Assuming, that I have a custom field named “position”, would it be possible to get only all files with “position: right” (or “position: left”)?

Well it is possible, but it would mean you would have to loop over every page and look in each page’s header for that position variable. That would be quite inefficient. Taxonomy is basically doing this and caching the results in a quick lookup table. So what your trying to do is what Taxonomy is built for.

Continuing my example… If I want to sort the articles in that list, I create, say, a “featured-weight” taxonomy. Then, e.g., in the first two featured articles’ .md files, I have:

featured-weight: 100

and

featured-weight: 10

…And now how can I use this new taxonomy to sort them? I’ve checked, and this is not documented yet…

( Hum, I think featured-weight should be featuredWeight instead, right? )

BTW, a “sort by date” example (most recent first) would be great, too. Thanks!

Yah dashes are not valid variable characters, can be camel case featuredWeight or underscores featured_weight

The thing about taxonomy is that the values are stored and used to map to the article. This means that you can’t really compare one against another to providing sorting.

There are a number of sort options available so perhaps you can use date combined with featured to get your desired result?

Hah, just was typing that!

:smiley:

OK, so manual positioning isn’t possible here?..

BTW, say that I want to hand pick 3 articles (from time to time) to be featured… Without having to copy/paste their info (which, in my case, is page.title, page.url, and a custom description), could I reference them somehow? This sort of thing can be quite useful…

It is possible to use manual ordering, and do what your asking with a taxonomy based collection. Read this section of the docs

This was tested in development and should work as advertised :slight_smile:

OK, basically I have two kinds of lists, a “featured articles” one and a “latest articles”… I’ll see if I can get it by reading the docs. :slight_smile: Thanks!

…Meanwhile, please let me know if I can go the “hand pick 3 articles” route I mentioned above for the “featured articles” list…

You can use multiple taxonomies to filter more. Read the taxonomy docs to see how to use compound taxonomy queries.