Hiding the sitewide name and Headernav from a Single Page

Permalink
I know that concrete5 inserts the single page in between the header and footer of the theme, but what if on a certain page I want to hide these sidewide components without removing them from the rest of the site?

Thanks in advance!

View Replies: View Best Answer
jordanlev replied on at Permalink Best Answer Reply
jordanlev
The easiest way is to put an "if" statement in your theme's view.php file (which is where the "header and footer" that c5 inserts single_page content into goes). The if statement checks if it's the special page, and if so it has its own set of markup for the header and footer (or none at all if that's what you want to do).

Since single_pages always need to exist at a specific path in your site, you can check for this page like so:
<?php if ($c->getCollectionPath() == '/path/to/your/single/page'): ?>
  <!-- do stuff here for your special single_page -->
<?php else: ?>
  <!-- do stuff here for all the other pages -->
<?php endif; ?>


Or if you have a controller you could have it pass a variable to the view with $this->set('is_special_page', true) ... then your if statement can be "if (isset($is_special_page))...".

Hope that helps!

-Jordan
ecerney replied on at Permalink Reply
Worked great, thanks! I was just hoping there was a way from the dashboard to maybe add some kind of property to the single page to remove it from global things like that, but I guess it takes a little code to get the logic down.
MelissaAmara replied on at Permalink Reply
Thank you for this piece of code Jordanlev

I'm building a single page on my site that will use a different theme, a mobile version. But when I test it, the header from the normal version is appearing. I put your code in both the main theme view.php and the mobile page theme view.php (see below), but there is no change.

<?php if ($c->getCollectionPath() == '/mobile'): ?>
  <!-- header_remove -->
  <?php else: ?>
  <!-- header_view -->
<?php endif; ?>