Creating a page type with NO GLOBAL HEADER
Permalink 2 users found helpfulI have attempted to follow your very clear instructions, however the header.php file in my theme is seemingly very complex, and I can't figure out where your code would go:
<div id="banner"> <div id="top"> <div class="row"> <div class="twelve columns banner-container"> <?php $a = new GlobalArea('Global Header Top'); $a->setBlockLimit(1); $a->display(); ?> <?php $a = new Area('Header Top'); $a->setBlockLimit(1); $a->display($c); ?> </div>
<div id="banner"> <div id="top"> <div class="row"> <div class="twelve columns banner-container"> <?php $page = Page::getCurrentPage(); $typeHandle = $page->getCollectionTypeHandle(); if ($typeHandle != 'noheader') { $a = new GlobalArea('Global Header Top'); $a->setBlockLimit(1); $a->display(); } ?> ...........................
ought to be something like what you want. If the page type handle is "noheader", then the GlobalArea is not declared, and consequently its site wide content is not displayed.
In this case the "Add to Sitewide Global Header Top" you would normally be seeing when editing a page will no longer appear. Figure out what the area name is, and then edit like I've done above.
...and don;t forget you will need to create the noheader page type by going to /index.php/dashboard/pages/types/add/ and creating the page type using the handle "noheader".
does that apply as well for the footer?
how would i remove the footer as well to have a plain page?
thanks in advance
kfog
_kfog
<?php
$a = new GlobalArea('Header Nav Alt');
$blocks = $a->getTotalBlocksInArea($c);
if($blocks > 0 || $c->isEditMode()) {
echo '<div class="c5h-navigation-wrap clearfix">';
echo ' <div class="row">';
echo ' <div class="small-12 columns">';
$a->setCustomTemplate('autonav', 'top_bar');
$a->display();
echo ' </div>';
echo ' </div><!-- END .row -->';
echo '</div>';
}
?>
What, precisely, do I need to change in this code to prevent the navigation from displaying, assuming I use the handle "noheader" for the page type I am trying to create?
<?php $page = Page::getCurrentPage(); $typeHandle = $page->getCollectionTypeHandle(); if ($typeHandle != 'noheader') { // if collection does not equal 'noheader' continue $a = new GlobalArea('Header Nav Alt'); $blocks = $a->getTotalBlocksInArea($c); if($blocks > 0 || $c->isEditMode()) { echo '<div class="c5h-navigation-wrap clearfix">'; echo ' <div class="row">'; echo ' <div class="small-12 columns">'; $a->setCustomTemplate('autonav', 'top_bar'); $a->display(); echo ' </div>'; echo ' </div><!-- END .row -->'; echo '</div>';
What I'd do is this: In the dashboard, create a new page type using the handle "noheader".
You'll now need to edit your theme's elements/header.php and find the part where it declares the global area. Edit it so that it looks like this:
Finally, you'll need to change the page type (using the design option) and switch it to "noheader". This should prevent the global area from being shown on any pages where the type is "noheader".
You might also need to copy one of your existing templates to "noheader.php", since the default.php will be used for any page types that don't have their own template. For instance, you might want to copy right_sidebar.php to noheader.php so that your headerless pages have a right sidebar.
if your area is actually in the page template itself, and not in the element, then simply copy your favourite template to noheader.php and remove the two lines declaring the global area.