15
votes
Accepted
How can I create a visually weighted tag cloud?
Brandon commented on getting tag usage count (and how it can be expensive) in this Google+ post and again in this SE question where I was trying to think through a plugin.
So to completely steal from ...
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 ...
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:
...
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
Showing the month on an archive page
Figured out a way to do this if anyone who has the same problem.
{% if year is defined and month is defined %}
{% set archiveDate = year ~ '-' ~ month ~ '-01' %}
<h2 class='archive-...
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()...
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 %}
...
5
votes
Creating a date filtered archive template
I've used this method for sorting by year and month (it could be expanded to support days).
On the news/index.html template:
{% if month is defined %} {# show an archive of a month #}
{% set ...
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 ...
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) %}
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 ...
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) %}...
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
:)
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 ...
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)....
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
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()....
1
vote
Creating a date filtered archive template
I ended up getting my archive list working using 'after' and 'before' parameters like below.
{% if year is not defined %}
{% redirect "news/archives/"~now.year %}
{% endif %}
{% set year = ...
Only top scored, non community-wiki answers of a minimum length are eligible