我有两个看似完全相同的模板,但branson.html
广告在每五个高尔夫球场后正确显示,但在ozarks.html
它们没有。我在这个问题的最底部发布了以前StackOverflow question的解决方案。
branson.html
至ozarks.html
,然后只需更改标签fab text update
course.region
== "Ozarks"
<div class="featured">
<div class="courses courses--featured">
{% set count = 0 %}
{% for content in COPY.courses %}
{% if content.region == "Ozarks" %}
<div class="course course--featured featured--region">
{% if content.featured == "Featured" %}
<a href="/courses/{{ content.slug }}"><img src="" class="course__image image--region"></a>
{% endif %}
<div class="course__inner inner--region">
<div class="course__wrapper">
{% if content.state == "MO" %}
<p class="course__state">Missouri</p>
{% elif content.state == "IL" %}
<p class="course__state">Missouri</p>
{% endif %}
</div>
<div class="course__wrapper">
<a href="/courses/{{ content.slug }}"><p class="course__name name--region">{{ content.name }}</p></a>
</div>
{% if content.featured == "Featured" %}
<p class="course__desc">{{ content.description }}</p>
{% endif %}
</div>
</div>
{% set count = count + 1 %}
{% if loop.index % 5 == 0 %}
<div class="advertising advertising--inline">
<div class="ad ad--rect">
<div class="text-center hidden-xs">
<div id="fixed-leaderboard-region-top"
class="dfp-ad"
data-dfp-custom-pos="fixed-leaderboard-top, htf"
data-dfp-size="[728,90]">
</div>
</div>
<div class="text-center hidden-sm hidden-md hidden-lg">
<div id="fixed-leaderboard-region-top-mobile"
class="dfp-ad"
data-dfp-custom-pos="fixed-leaderboard-top, htf"
data-dfp-size="[320,50]">
</div>
</div>
</div>
</div>
{% endif %}
{% endif %}
{% endfor %}
</div>
</div>
<div class="featured">
<div class="courses courses--featured">
{% set count = 0 %}
{% for content in COPY.courses %}
{% if content.region == "Branson" %}
<div class="course course--featured featured--region">
{% if content.featured == "Featured" %}
<a href="/courses/{{ content.slug }}"><img src="" class="course__image image--region"></a>
{% endif %}
<div class="course__inner inner--region">
<div class="course__wrapper">
{% if content.state == "MO" %}
<p class="course__state">Missouri</p>
{% elif content.state == "IL" %}
<p class="course__state">Missouri</p>
{% endif %}
</div>
<div class="course__wrapper">
<a href="/courses/{{ content.slug }}"><p class="course__name name--region">{{ content.name }}</p></a>
</div>
{% if content.featured == "Featured" %}
<p class="course__desc">{{ content.description }}</p>
{% endif %}
</div>
</div>
{% set count = count + 1 %}
{% if loop.index % 5 == 0 %}
<div class="advertising advertising--inline">
<div class="ad ad--rect">
<div class="text-center hidden-xs">
<div id="fixed-leaderboard-region-top"
class="dfp-ad"
data-dfp-custom-pos="fixed-leaderboard-top, htf"
data-dfp-size="[728,90]">
</div>
</div>
<div class="text-center hidden-sm hidden-md hidden-lg">
<div id="fixed-leaderboard-region-top-mobile"
class="dfp-ad"
data-dfp-custom-pos="fixed-leaderboard-top, htf"
data-dfp-size="[320,50]">
</div>
</div>
</div>
</div>
{% endif %}
{% endif %}
{% endfor %}
</div>
</div>
{% set count = 0 %}
{% for content in COPY.courses %}
{% if content.featured == "Test" %}
<div class="course course--featured">
<a href=""><img src="" class="course__image image--home"></a>
[...]
</div>
</div>
{% set count = count + 1 %}
{% if count % 5 == 0 %}
<!-- additional content once every 5 courses -->
{% endif %}
{% endif %}
{% endfor %}
答案 0 :(得分:0)
这很容易解决。
在ozarks.html
模板上,它使用了loop.index
而不是count
设置得更高,以确定广告的放置位置。