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

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

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

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

Works like a charm, thanks Scott!

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

hmm, maybe you should read this - http://octobercms.com/docs/cms/components#viewbag-component

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

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

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

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.