Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Django-CMS slug in if statement in HTML

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>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading