14 votes

How can I create a visually weighted tag cloud?

Marion Newlevant had a clever, efficient idea in this Straight Up Craft Hangout if you don't mind having a slight lag (like a day) for your tag counts to be up to date. That idea: store the counts you ...
  • 3,986
9 votes
Accepted

Linking and showing archive by month

So P&T chipped in to help and of course solved my plight immediately :D For anyone else who might encounter a similar scenario I'm posting the solution. On the page containing the archive list: ...
  • 1,193
8 votes
Accepted

Creating an archive page with full year and month list

{% set groupedEntries = entriesInYear | group("postDate|date('F')") %} Will give you an associative array where the keys are the months, and the values are the entries for that month. Now you need ...
7 votes
Accepted

Filter entries by month

The value you need to set the postDate parameter to is quite complex. If you define a dedicated variable for it, it makes the code more readable and you can more easily debug the value using the dump()...
  • 36k
5 votes
Accepted

SEO titles/descriptions for tags and archive pages

The better approach in my opinion is to declare the variables in the corresponding templates rather than in the _layout template Layout.twig {% if seoTitle is not defined or seoTitle is empty %} ...
2 votes
Accepted

Archive page - only show posts from certain month

There's probably a cleaner way to go about this, but something like this should work: {# These are probably coming from the querystring, but I'll hard code them here #} {% set year = 2015 %} {% set ...
  • 66.9k
2 votes

Date conversion returning December for every single digit month representation

Here's what's happening... Every time you get "December", it's because the date is being parsed as December 31, 1969 (aka, just before the Unix Epoch). Basically, it's failing to parse the date ...
  • 23.8k
2 votes
Accepted

Archive Not Returning Correct Date Variable

Your postDate.day will output the number of the day in the month so if your entries postdate is 02.dd.yyyy your output is 2. Your array index will be something like [2, 3, 5, 12, 31] thus these values ...
2 votes
Accepted

How do I pass a URL segment to a search parameter?

You'd need to use Twig's string concatenation in order to do this with the ~ operator. {% set entries = craft.entries.section('calendar').search('eventstart:' ~ year ~ '-' ~ month) %}
  • 66.9k
2 votes
Accepted

Event archives with custom date field

Try this: {% set entriesInYear = craft.entries .section('agenda') .limit(null) . dateAndTime([ 'and', '>=' ~ year, '<' ~ (year + 1) ]) .all() %} The ...
2 votes
Accepted

Change order within grouped archive

Assuming the years are currently rendered in the correct (descending) order, an easy way to make sure the entries are rendered in ascending order would be to simply reverse the entriesInYear array, i....
1 vote

My month/year archive template code no longer works in 3.2

This should be fixed for the upcoming 3.2.11 release. To get the fix early, change your craftcms/cms requirement in composer.json to: "require": { "craftcms/cms": "dev-develop#...
1 vote
Accepted

Displaying a month name in an archive

Try this: {% set year = craft.request.segment(4) %} {% set month = craft.request.segment(5) %} {% set entriesInYear = craft.entries.section('bulletinOnline').limit(null).after(year).before(year+1) %}...
  • 66.9k
1 vote

Archive page date logic stopped working

It seems that before and after() don't work with the year as an int, if instead of '2018', you use '2018-01-01', your code works again. Check this. Basically, use a DateTime object :)
  • 7,340
1 vote

Linking and showing archive by month

The code on the left is what you want to use... Here are the general steps to follow to put everything together. Since you're creating an archive page, you have to explicitly tell Craft what to do. ...
1 vote

Is it possible to use same template for index and archive template?

The way I do this is to use a different template for each set of entries. So there would be an archive one for all the articles from a given month: _news/index-archive, and a category one for all the ...
1 vote

I can't get Tags and Archive pages to appear

Sounds like you are missing a few tags, which we can fix when you post your code. Meanwhile, if you can spare the time, checkout Mijingo.com Craft Essentials, it's like being in the matrix as within ...
  • 598
1 vote
Accepted

Date Archives: Last 6 months

100% untested, but something like this should work using Twig's date_modify filter. {% set startDate = now|date_modify("-6 months") %} {% set allEntries = craft.entries.section('blog').limit(null)....
  • 66.9k
1 vote
Accepted

Changing the order of an 'archive' page

If you change your query and sort by ascending postdate, it will start with the oldest and end with the newest: {% set entriesInYear = craft.entries.section('blog').limit(null).after(year).before(...
  • 1,342
1 vote
Accepted

Date conversion returning December for every single digit month representation

You can't create a date from a single digit. This is what I would do instead: Get the localized names from Craft's data set with this function: {% set monthName = craft.i18n.getLocaleData()....
  • 36k

Only top scored, non community-wiki answers of a minimum length are eligible