Skip to content

Instantly share code, notes, and snippets.

@cherrykoda
Created July 13, 2020 14:10
Show Gist options
  • Save cherrykoda/5eb3a4dab34c05e9f7aaf0d05391e140 to your computer and use it in GitHub Desktop.
Save cherrykoda/5eb3a4dab34c05e9f7aaf0d05391e140 to your computer and use it in GitHub Desktop.
[Medium] Macros v. Partials - State Sport Articles
{% set sportArticles = craft.entries.section('articles').relatedTo(['and',
{ element : state },
{ element : sport }
]) %}
{# Set Popular Articles #}
{% do craft.views_work.sortPopular(sportArticles, 'month') %}
{% set popularArticles = sportArticles.limit(6).all %}
<div class="hero" {% if sport %}style="background: url({{ sport.sportBackground.one.url('sportBg') }}) center center no-repeat; background-size: cover;"{% endif %}>
<div class="container">
// Hero Content
</div>
</div>
{% if popularArticles|length %}
{% include '_components/_popular-now' with {
articles: popularArticles
}%}
{% endif %}
<div class="content">
<div class="container">
// Body Content
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment