This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Aebian
Aebian

{% if this.page.id == 'home'%}

Renatio
Renatio

It should work :)

Use following code in layout to check what is inside page variable.

{{ dump(this.page) }}

Follow documentation.

Better option will be adding class to navbar like this:

<nav class="page-{{ this.page.id }}">

and style it in your CSS.

Last updated

Scott
Scott

You could always use the viewBag component for this sort of thing.

Layout

description = "Default layout"
==
<html>
    <head></head>
    <body>
        {% if viewBag.nav == 'big' %}
            <!-- Big nav here -->
        {% else %}
            <!-- Normal nav here -->
        {% endif %}

        {% page %}

    </body>
</html>

Home page

title = "Home"
url = "/"
layout = "default"
hidden = "0"

[viewBag]
nav = "big"
==
Blah Blah Blah... My nav is big!

Some other page

title = "About"
url = "/about"
layout = "default"
hidden = "0"
==
Blah Blah Blah... My nav is normal!

Last updated

Aebian
Aebian

Works like a charm, thanks Scott!

Cpt.Meatball
Cpt.Meatball

How does the viewBag work in code exactly? Can't seem to figure it out. :/

raw99
Cpt.Meatball
Cpt.Meatball

Yeah. Boo-Hoo. That's what I don't get. :P Where do you fill the Viewbag?

raw99
raw99

Cpt.Meatball said:

Yeah. Boo-Hoo. That's what I don't get. :P Where do you fill the Viewbag?

Read again! Edit htm with any html editor...

[viewBag]

activeMenu = "about"

After that simply ask: <li class="{{ viewBag.activeMenu == 'about' ? 'active' }}></li>

As we defined that activeMenu = "about", <li> will have a class "active" else it will have empty class...

Last updated

Cpt.Meatball
Cpt.Meatball

So you need to edit the .htm file with outside of the CMS? It can just be me, but that's not even remotely October-ish.

But thanks! :D

raw99
raw99

Cpt.Meatball said:

So you need to edit the .htm file with outside of the CMS? It can just be me, but that's not even remotely October-ish.

But thanks! :D

Yea, I haven't found any way how to edit these things with stock editor... I'm editing all from IDE anyway, so I don't care about that... haha...

Last updated

1-10 of 10

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.