Hey there!
I’m creating a few custom templates and my site consists of several pages - one of them is /blog, where I have a foreach-loop to display all posts (either in German or English).
My site is in two languages, therefore I work a lot with has-helpers and tags like {{#has tag="#en"}}
. My problem is that in my blog template after including the pagination - for everything after the pagination {{#has tag="#en"}}
doesn’t work anymore.
This is my blog.hbs template:
<!DOCTYPE html>
<html lang="{{#page}}{{#has tag="#en"}}en{{else}}{{@site.locale}}{{/has}}{{/page}}">
{{> "head"}}
<body class="page-blog {{body_class}}">
{{> "header"}}
<div class="page-content">
{{> "blog-header"}}
<div class="container">
<div class="wrapper">
<article class="post-list">
{{#foreach posts}}
{{> "post-excerpt"}}
{{/foreach}}
{{pagination}}
</article>
</div>
</div>
</div>
{{> "footer"}}
</body>
</html>
Everything before the pagination is displayed in the correct language, but unfortunately my footer is always displayed in German, because it seems like every {{#has tags="#en"}}
is being ignored after the {{pagination}}
. As soon as I remove the pagination, everything is fine.
This is my pagination.hbs:
<div class="pagination-container">
{{#if prev}}
<a href="{{page_url prev}}" class="previous"><i data-feather="chevron-left"></i> Newer posts</a>
{{/if}}
{{#if next}}
<a href="{{page_url next}}" class="next">Older posts <i data-feather="chevron-right"></i></a>
{{/if}}
<div class="clearfix"></div>
</div>
Any ideas?
Hi
I’m not sure what’s happening from what you provided. Can you share your footer.hbs code?
Yes sure, this is my footer:
<footer class="site-footer revealOnScroll" data-animation="fadeInUp">
<div class="wrapper-flex">
<div class="open-form-modal">
<span>
{{#page}}{{#has tag="#en"}}Let's talk about your next project{{else}}Lassen Sie uns über Ihr Projekt sprechen{{/has}}{{/page}}
{{#post}}{{#has tag="#en"}}Let's talk about your next project{{else}}Lassen Sie uns über Ihr Projekt sprechen{{/has}}{{/post}}
</div>
<div class="footer-col-wrapper">
<div class="footer-col footer-col-1">
<ul class="contact-list">
<li class="symbol"><a href="{{#page}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/page}}{{#post}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/post}}"><i data-feather="map-pin"></i></a></li>
<li><a href="{{#page}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/page}}{{#post}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/post}}">D-81737 {{#page}}{{#has tag="#en"}}Munich{{else}}München{{/has}}{{/page}}{{#post}}{{#has tag="#en"}}Munich{{else}}München{{/has}}{{/post}}</a></li>
<li><a href="{{#page}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/page}}{{#post}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/post}}">D-86150 Augsburg</a></li>
<li><a href="{{#page}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/page}}{{#post}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/post}}">D-10997 Berlin</a></li>
<li><a href="{{#page}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/page}}{{#post}}{{#has tag="#en"}}/contact/{{else}}/kontakt/{{/has}}{{/post}}">D-93051 Regensburg</a></li>
</ul>
</div>
<div class="footer-col footer-col-2">
<ul class="imprint-links">
{{#page}}{{#has tag="#en"}}
<li><a href="/legal-notice/">Legal Notice</a></li>
<li><a href="/privacy-policy/">Privacy Policy</a></li>
<li><a href="/contact/">Contact</a></li>
<li><a href="/jobs-en/">Jobs</a></li>
<li><a href="/blog/de/2017/06/1-pledge">1% Pledge</a></li>
{{else}}
<li><a href="/impressum/">Impressum</a></li>
<li><a href="/datenschutz/">Datenschutz</a></li>
<li><a href="/kontakt/">Kontakt</a></li>
<li><a href="/jobs/">Jobs</a></li>
<li><a href="/blog/de/2017/06/1-pledge">1% Pledge</a></li>
{{/has}}{{/page}}
{{#post}}{{#has tag="#en"}}
<li><a href="/legal-notice/">Legal Notice</a></li>
<li><a href="/privacy-policy/">Privacy Policy</a></li>
<li><a href="/contact/">Contact</a></li>
<li><a href="/jobs-en/">Jobs</a></li>
<li><a href="/blog/de/2017/06/1-pledge">1% Pledge</a></li>
{{else}}
<li><a href="/impressum/">Impressum</a></li>
<li><a href="/datenschutz/">Datenschutz</a></li>
<li><a href="/kontakt/">Kontakt</a></li>
<li><a href="/jobs/">Jobs</a></li>
<li><a href="/blog/de/2017/06/1-pledge">1% Pledge</a></li>
{{/has}}{{/post}}
</ul>
</div>
</div>
</div>
</footer>
I’m using similar has-else-helpers in my header, which is working fine. Only the footer on my english Blog-page (which is tagged with “#en”) is displayed in German. As soon as I remove the pagination, it’s displayed in English, how it should be.