What does this code mean?
Permalink
Hello Concrete5 members,
Can somebody explain what this code means:
This is the code of the elemental theme footer.php from Concrete5.
Can 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.
So I can hide area's when there is no block added ?
That is quiet cool.
That is quiet cool.
Yes, you can but that's actually not very useful. When an area is empty, no need to hide it, it doesn't use up any space.
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.
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.
Hiding areas can also be useful when they are either columns ( that take up width regardless if there is content in them), or when the area has any padding (because padding adds height regardless if there's content, it will even override min-height: 0).
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