Hide all regions in a page

Public
</> CopyGet raw version
php
  1. #template.php
  2.  
  3. <?php
  4.  
  5. /**
  6.  * Override or insert variables into the block templates.
  7.  *
  8.  * @param $variables
  9.  * An array of variables to pass to the theme template.
  10.  * @param $hook
  11.  * The name of the template being rendered ("block" in this case.)
  12.  */
  13. /* -- Delete this line if you want to use this function
  14. function mytheme_preprocess_block(&$variables, $hook) {
  15.   // Add a count to all the blocks in the region.
  16.   $variables['classes_array'][] = 'count-' . $variables['block_id'];
  17. }
  18. // */
  19.  
  20. function mytheme_preprocess(&$variables, $hook) {
  21. if ($variables['is_front']) {
  22. switch ($hook) {
  23. case 'html':
  24. // Override the node title and use a custom title
  25. // for the front page.
  26. $variables['head_title'] = t('Welcome to My site!');
  27. break;
  28. case 'region':
  29. // Empty all regions besides the content.
  30. if ($variables['region'] != 'content') {
  31. $variables['content'] = '';
  32. }
  33. break;
  34. case 'page':
  35. // Do not display the node title for the front page.
  36. $variables['title'] = '';
  37. break;
  38. case 'node':
  39. // Hide submission information and links.
  40. $variables['display_submitted'] = FALSE;
  41. unset($variables['content']['links']);
  42. break;
  43. }
  44. }
  45. }

Comments

Manjit's picture

Is there code tested ? OR Can we use this code directly without any testing ?