I am trying to write an if statement to change what the link links to, based on the slug URL. I get an error in the if_statement. Shouldn't this work?
<div>
{% if page_attribute "slug" == 'hjem' or page_attribute "slug" == 'home' %}
<a href="/no/">NO</a> / <a href="/en/">EN</a>
{% else %}
<a href="/no/{% page_attribute 'slug' %}">NO</a> / <a href="/en/{% page_attribute 'slug' %}">EN</a>
{% endif %}
</div>
CodePudding user response:
You can try this...
{% page_attribute "slug" as page_slug %}
<div>
{% if page_slug == 'hjem' or page_slug == 'home' %}
<a href="/no/">NO</a> / <a href="/en/">EN</a>
{% else %}
<a href="/no/{% page_slug %}">NO</a> / <a href="/en/{% page_slug %}">EN</a>
{% end if %}
</div>
CodePudding user response:
I don't think you can use template tags in an "if" statement. You'll have to find some other way to get the slug URL.