New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

sub group_by for {{ entries }}

Jon Roobottom September 18, 2014 by Jon Roobottom

This isn't a feature request, rather a 'how do I' by hacking what is in Statamic now.

  1. On my homepage I wish to display the contents of my blog and photos folders
  2. These should be grouped by day, and only the most recent 5 days with any content shown (for example: if There was only content published [3,16,22,26,33] days ago, it should just show those days)
  3. I wish to then further group my photos by hour "At around 6pm I took 3 photos", etc.
  4. Finally, photos and blog posts should be able to be styled differently.

Here's the content of my default.html file so far:

<h1>{{ title }}</h1>
{{ entries:listing folder="blog|photos" group_by_date="l, jS F Y" since="-2 years" }}
    {{ if grouped_date }}
        {{ if !first }}
        {{ /if }}

        <h3>{{ grouped_date }}</h3>
    {{ endif }}

        <a href="{{ url }}">{{ url }}{{ title }}</a>

    {{ if last }}
    {{ /if }}
{{ /entries:listing }}

Hope all that makes sense! Thanks in advance for your help.

Answered by Jon Roobottom!
>>>>>>> Answered <<<<<<<
5 Replies
1 Follower