1

I'm trying to show a menu based on what group a user is in once they have logged in. However, I'm not having any success. Here is an example (for one of the groups) of what I have in my _base.html file, which I'm extending in my other pages:

{% if currentUser.isInGroup('advisors') %}
    <div class="secondary-navigation">
        <div class="row">
            <div class="small-1 columns group">
                <h2>Advisors</h2>
            </div>
            <div class="small-11 columns navigation">
                <ul>
                    <li><a href="">Advisors Home</a></li>
                    <li><a href="">Education</a></li>
                    <li><a href="">Blog</a></li>
                    <li><a href="">Events</a></li>
                    <li><a href="">Nav 5</a></li>
                </ul>
            </div>
        </div>
    </div>
{% endif %}

Any suggestions would be most welcome!

Jamie Wade
  • 3,644
  • 2
  • 16
  • 32
Todd
  • 284
  • 1
  • 6

1 Answers1

1

OK, so enabling the devMode helped point me in the right direction.

First, I needed to change it to

{% if currentUser and currentUser.isInGroup('advisors') %}

Otherwise I was getting an error message when nobody was logged in ("Impossible to invoke a method ("isInGroup") on a null variable").

Then I discovered that the user I was testing wasn't added to any groups! I could have sworn I set up the user with a group assigned, but apparently not. :(

Todd
  • 284
  • 1
  • 6