Global Area only visible when logged in

Permalink 1 user found helpful
I defined a global area for a site-wide navigation menu:
  $subNav = new GlobalArea('Sub Navigation');

Then, I added an autonav block to the global area.

As long as I'm logged in as administrator, the navigation menu is visible. But when I log out, it's gone.

I didn't set any permissions, it's an almost fresh installation of c5.6.0.2.

This solves my problem: If I delete the autonav block and add it again, it's visible both for administrators and guests.

Can anybody explain this to me?

View Replies: View Best Answer
tallacman replied on at Permalink Reply
Did you approve the changes once you made them? Otherwise they wont appear to the public.
karlertl replied on at Permalink Reply
Yes, of course.

UPDATE: Ah, now I see what you meant. I used to add blocks to global areas in the frontend (that means directly on the page). Most of the time, this worked. But sometimes, I ran into the problem described above.

Now, I tried to add blocks via Dashboard > Stacks & Blocks > Stacks. Here, I can see the Approve button you probably talked about. If I add blocks here and immediately click the Approve button, everything works like a charm.

I don't know if this is a bug or not. Maybe global areas are not intended for adding blocks in the frontend?
adajad replied on at Permalink Reply
You got the code wrong
  $subNav = new GlobalArea('Sub Navigation');
  $subNav->display($c);  //you missed your $c variable to display on page
karlertl replied on at Permalink Reply
Actually, my code isn't wrong - you can leave out "$c" when you define a global area.

Have a look at the default c5 templates or here:
adajad replied on at Permalink Reply
Hmm... I have looked at all core themes default.php and all of them supply $c, but you are right in that the how-to does leave it out.

Though in the developer documentation it clearly state you should supply the page (scroll down to the bottom):

Have you tried it?

Edit: Ah... GlobalArea... You are right, they don't hold $c in the core themes.
karlertl replied on at Permalink Reply
Yep. But I guess I found the reason. See my reply above.
adajad replied on at Permalink Reply

Tallacman was right all along. I'm with you on this one as I have missed the approve button a few times myself.
rainmaker replied on at Permalink Reply
Don't worry karlerti!

I didn't realize you needed to approve the changes either. :) I only just found that out thanks to you!
snapcridge replied on at Permalink Reply
Wanted to chime in. In case someone else ran into this issue. Make sure you get good sleep and check your permissions on that block as Tallacman said. If you remove permissions for a group, but turn on permissions manually for a specific page, you will need to manually enable permissions for that global block from the same aforementioned (Stacks) area.
karlertl replied on at Permalink Best Answer Reply
After playing around for quite a long time, I found the final explanation:

I had two global areas on my page: one for the main navigation and one for the sub navigation. In the frontend, I added autonav blocks to both areas immediately after each other and then published the page.

The first block (main navigation) worked fine immediately, but the second block (sub navigation) required to go to Dashboard > Stacks & Blocks > Stacks > Sub Navigation > Approve Changes.

That's it!
You shouldn't add blocks to several global areas at once.
WebStudioEast replied on at Permalink Reply
That helped me - thanks!