How to block all the blocks for perticular content type?

Comments

Anandyrh’s picture

I have a content type called 'test', I need to disable Header, sidebars and fotter for this content type.
I just need content to be in this content type.

Any Idea to do this?

yasir farooqui’s picture

You should create a separate template file with in your theme for that specific content type and remove the regions in that file that you do not want to show. For example if your content type is "test", then the new template file will be called "page-test.tpl.php"

Now you will need to write this code in your template.php (create a file with this name if it does not exists) file:

function themename_preprocess_node(&$variables) {
  
  
  if($variables['node']->type == 'test')
  {
  	$variables['template_file'] = 'page-test';
  }
	
} 

Note that this solution is for Drupal 6 and you will need to clear drupal's cache after following these steps.

Anandyrh’s picture

I did it but it's not working!

After doing this now i can see header and footer inside the content part. but the main header, sidebars and footer is still visible.

I just need to disable header, sidebars and footer from the 'test' content type.

yasir farooqui’s picture

Did you remove header, sidebars and footer from new template file?

Anandyrh’s picture

Yes did

Anandyrh’s picture

Did you got it working anytime?

Why it's not working for me?

Any idea?

yasir farooqui’s picture

Yes it always works for me, I have used it so many times. Can you tell me the steps that you exactly followed. Also can you send here the function code that you have written in template.php file.

Anandyrh’s picture

I have a file called page-test.tpl.php for this page i have copied code from page.tpl.php

and then i have removed the areas which i don't need it to visible (like: header, sidebars).

This code is pested in template.php file

function greenNblack_preprocess_node(&$variables) {
  
  if($variables['node']->type == 'test')
  {
  $variables['template_file'] = 'page-test';
  }

} 

is this right?

yasir farooqui’s picture

Ummm... the work you have done seems fine. Did you clear drupal cache?

Anandyrh’s picture

Yup!

PostHistory’s picture

did you end up getting this to work ?

also where were these files contained because i can find more than one template.php file........

one in the current theme directrory, and another in the sites/all/themes directory.

also i have cleared my cache and im still stuck with the header in one page i dont want it to appear on. http://www.beta.entropiamedics.com/im

go figure... :)

Liam Mitchell’s picture

function customtheme_preprocess_page(&$vars, $hook) {

  if($vars['node']->type == 'pagenosb')
  {
  $vars['template_file'] = 'page-nosb';
  }
}

it needed to be in the page preprocess function to apply the custom tpl to the page instead of the node

pagenosb is my custom content type, stands for page no sidebars

i then needed to remove zen body classes that were still applying sidebar theming even though sidebars were not printed

i don't know much php but this seemed to have worked

  $body_classes = $vars['body_classes'];
  $body_classes = str_replace(array('sidebar-left','sidebar-right', 'one-sidebar', 'two-sidebars'), "", $body_classes);
  $body_classes = str_replace('  ', ' ', $body_classes);
  if (strpos($body_classes, 'no-sidebars') === false ) {
	$body_classes .= ' no-sidebars';
}
$vars['body_classes'] =  $body_classes;