3

I want to create a special content type that doesn't include the logo and main navigation. I have a helper module and have added the following section before renenabling it but it doesn't seem to be having an affect. What might I be doing wrong?

function myhelpermodule_page_alter(&$page) {
  if (current_path() == 'node/add/specialcontenttype') {
    unset($page['header']);
  }
}

Just in case I got "header" wrong, I've tried it with 'footer' and other regions to test it out and it seems to be having no affect at all.

2 Answers 2

2

Create a hook suggestion in page preprocess and theme that page

for eg:

function yourthemename_preprocess_page(&$vars) {
  if (isset($vars['node']->type)) {
    $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
}

Now clear the caches Duplicate page.tpl.php and rename it as page--specialcontenttype.tpl.php

Then, remove the <?php print render($page['header']); ?> etc.. from it

0
1

The easiest way I've found to achieve this is to have a custom page.tpl.php file for your particular content type. That way you can remove the regions you don't need from the specific template file.

It's easily done with a few lines of code in your theme's template.php file and creating a new page template file. You'll find lots of tutorials online.

Here's one to get you started: https://www.digett.com/insights/overriding-page-templates-content-type-drupal-7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.