What does this code mean?
PermalinkCan somebody explain what this code means:
$footerSiteTitle = new GlobalArea('Footer Site Title'); $footerSocial = new GlobalArea('Footer Social'); $footerSiteTitleBlocks = $footerSiteTitle->getTotalBlocksInArea(); $footerSocialBlocks = $footerSocial->getTotalBlocksInArea(); $displayFirstSection = $footerSiteTitleBlocks > 0 || $footerSocialBlocks > 0 || $c->isEditMode();
This is the code of the elemental theme footer.php from Concrete5.
That is quiet cool.
It is useful when for instance yu have a <div> around the area and you want to hide it so you don't have an empty <div> laying around.
Or maybe you want to show some default text or image or other when the area is empty.
That variable tells you when the areas are empty or not and you can do anything you want with it.
For a short version: if any of the 2 global areas 'Footer Site Title' or 'Footer Social' has more than 1 block in it, or if the page is in edit mode, then the variable $displayFirstSection will be set to TRUE. Otherwise, if both areas contain no blocks AND the page is not in edit mode, it will be set to FALSE.
For a longer version, here's the code with comments. Hope it helps