Creating a page type with NO GLOBAL HEADER

Permalink 2 users found helpful
I need a page type that does not display the Global Header. I have tried making a new page type and removing the "includes", and I have tried creating a "single page", but cannot figure tis out. Anybody?

 
jero replied on at Permalink Reply
jero
That largely depends on where the global header is located. Most themes have a header.php located in the elements folder that typically would have the globalarea declared in it.

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:

$page = Page::getCurrentPage();
$typeHandle = $page->getCollectionTypeHandle();
if ($typeHandle != 'noheader') {
      $header = new GlobalArea('Header');
      $header->display($c);
}


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.
michaelbard replied on at Permalink Reply
Thank you Jero,

I 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>
jero replied on at Permalink Reply
jero
Look for occurrences of "GlobalArea" - these are the so called "Sitewide" areas you see when editing a page. Using your code:

<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".
michaelbard replied on at Permalink Reply
Wow, thank you man! This works perfectly. Now I have so much more flexibility in placing my content. You ROCK!
jero replied on at Permalink Reply
jero
You're welcome. Glad you got it working.
kfog replied on at Permalink Reply
kfog
jero, thanks for the instructions. that works.
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
jero replied on at Permalink Reply
jero
Yes, it should do. You can exclude practically any code using the page type handle test. Don't remove the Loader::element('footer_required') part though - otherwise you'll have no tool bar and will be unable to edit the page.
kfog replied on at Permalink Reply
kfog
jero, thanks. that's quite a useful, even powerful thing.
_kfog
Dushka replied on at Permalink Reply
Dushka
Three years have passed since this question was asked. "Things" have obviously changed since then. Could someone kindly answer the original question in light of developments since then. I would like to suppress the navigation on my landing pages. I am trying to create a "Landing Page" page type that does not display the nav. Here is what I think is the relevant part of the header.php file for my theme (Fundamental):

<?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?
ConcreteOwl replied on at Permalink Best Answer Reply
ConcreteOwl
Try this (untested)
<?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>';
Dushka replied on at Permalink Reply
Dushka
Brilliant. That worked a treat. Thank you so much.