Skip to content

Commit

Permalink
modify: 「固定表示フラグ」が ON の最新エントリの出力
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamseeker committed Dec 14, 2018
1 parent 3b725b8 commit cde9937
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions templates/news/index.html
Expand Up @@ -10,6 +10,13 @@
{# meta タイトル #}
{% set metaTitle = 'ニュース' %}

{# 「固定表示フラグ」が ON の最新エントリを取得 #}
{% set featuredEntry = craft.entries({
section: 'news',
featuredEntry: 1,
orderBy: 'postDate desc'
}).one() %}


{# ------------------------------------------
出力
Expand All @@ -27,23 +34,32 @@ <h1 class="alpha center reverse">Brew News</h1>
</div><!-- /.flex -->
</header><!-- /.alt2 -->
<div class="flex">
<article class="featured news-entry">
<figure>
<a href="../news/detail.html">
<img src="https://placehold.jp/3d4070/42598f/570x348.png" alt="water-barley-hops" width="570" height="348">
</a>
</figure>
<div class="summary-wrap">
<h3><a href="../news/barrel-aged-digital-natives">Barrel Aged Digital Natives</a></h3>
<span class="author">admin</span>
<p>
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis.
</p>
<p>
<a href="../news/detail.html" class="more-link">Read More</a>
</p>
</div><!-- /.summary-wrap -->
</article><!-- /.featured.news-entry -->

{# 「固定表示フラグ」が ON の最新エントリ #}
{% if featuredEntry %}
{# 「メイン画像」を取得 #}
{% set image = featuredEntry.featuredImage.one() %}

<article class="featured news-entry">
{# 「メイン画像」がセットされていれば、出力 #}
{% if image %}
<figure>
<a href="{{ featuredEntry.url }}">
<img src="{{ image.url }}" alt="{{ image.title }}" width="570" height="348">
</a>
</figure>
{% endif %}
<div class="summary-wrap">
<h3><a href="{{ featuredEntry.url }}">{{ featuredEntry.title }}</a></h3>
<span class="author">{{ featuredEntry.author.name }}</span>
{{ featuredEntry.shortDescription }}
<p>
<a href="{{ featuredEntry.url }}" class="more-link">Read More</a>
</p>
</div><!-- /.summary-wrap -->
</article><!-- /.featured.news-entry -->
{% endif %}

<article class="news-entry">
<figure>
<a href="../news/detail.html">
Expand Down

0 comments on commit cde9937

Please sign in to comment.