What are "Global Areas No global areas created yet."

Permalink 1 user found helpful
When you go to the Stacks section of 5.5.1 it also says:

"Global Areas No global areas created yet."

I hate to sound dense, but what are those?

dibbc
 
mesuva replied on at Permalink Best Answer Reply
mesuva
They are technically stacks, but they are automatically created when a global area is defined in the theme itself.

Normally in a template file you would create an area like this:
$a = new Area('Header Nav');
$a->display($c);


But now in 5.5, you can make it a global area by doing this instead:
$a = new GlobalArea('Header Nav');
$a->display($c);

There were sort of hacky ways to achieve this in 5.4.x, now this is a really nice way of having a common area across your pages.

Once concrete5 sees that global area, you'll see it in the stacks section and it's treated like a stack.
dibbc replied on at Permalink Reply
dibbc
So basically if your theme doesn't already have it, and if you don't modify the source code, it's not something you would/could use?
geniewish replied on at Permalink Reply
geniewish
I want to add a logo.gif and I have looked all over the web and the only thing that I find is that I go to "stacks" then "global area" and click on "site name".

The problem is that when I go to stacks I see this:
No global areas created yet.

Can anyone tell me how to create a global area, or give me the code to put in the header.php

FRUSTRATING...
manuelvalle replied on at Permalink Reply
manuelvalle
Insert the code posted by mesuva in your php template or header.php exactly where you want the logo, naming area as you want (Ex: Logo Placeholder):
$a = new GlobalArea('Logo Placeholder';
$a->display($c);


Now go to Stacks in the Dashboard.
A new Global Areas section was created with your Logo Placeholder inside.

Add an image block or other block you prefer with your logo.

Thats all.

Hoping this will help you.
dkroy replied on at Permalink Reply
dkroy
Just an FYI you have a typo the code should be:
$a = new GlobalArea('Logo Placeholder');
$a->display($c);


I figured I would clarify that just encase someone was copy and pasting your code.
dankoerner replied on at Permalink Reply
This just made my life 1000 times easier. Thank you very much!
TorstenKelsch replied on at Permalink Reply
TorstenKelsch
And you have to log out and in again to see the new global area in dashboard -> stacks.
Bashfulmonk replied on at Permalink Reply
Should it not be:

$a = new GlobalArea('Logo Placeholder');
$a->display( );


Just wondering as this is what I have always used?
orisinal replied on at Permalink Reply
orisinal
You're right, Bashfulmonk. The display method of GlobalArea doesn't want the $c parameter (c like Collection). It finds it out by itself.

/concrete/models/global_area.php
public function display() {
  $c = Page::getCurrentPage();
  parent::getOrCreate($c, $this->arHandle, 1);
  parent::display($c);
}


Howerver, normal Areas do need the collection.

/concrete/models/area.php
function display(&$c, $alternateBlockArray = null) {
  if(!intval($c->cID)){
    //Invalid Collection
    return false;
  }
  ...