Removing Drupal default welcome message

When I am in a hurry while designing a theme for Drupal, I just clone the default theme and alter its layout dimensions, colors and images.

When I tried doing so on Drupal 7, I first faced this error message

Notice: Undefined variable: hide_site_name in include()

Which is solved by replacing the default theme name with the new one in template.php (thanks to this post in drupal.org)

Then the second problem (which is actually an old one) was the default welcome message, I didn't want to create any node and promote it to front page and also didn't like the idea of an h1 tag with just a welcome message, but after a look into the code of page.tpl.php and template.php I found the solution.

I just needed to add this line to the function mythemename_process_page in the file template.php :

<?php
if (drupal_is_front_page()) {
$variables['title']="";
}
?>

The default theme (bartik) page.tpl.php file will then put the site name in the h1 tag instead of the welcome message, now there is no welcome message, the main header is the site name, no core editing ... everyone is happy.

But there is one more problem. which can be called the "no front page content" problem, obviously it's the message Drupal displays as the content of the front page if no nodes are promoted to front page.

Thanks to this post at drupal.org, I got the solution that was just adding one more line to the above code like this :-

<?php
if (drupal_is_front_page()) {
 
$variables['title']="";
  unset(
$variables['page']['content']['system_main']['default_message']);
}
?>

Notes:-

  • This code is to be put at the start of the function as the title variable is checked in the same function again.
  • I think it can be added to mythemename_page_preprocess rather than mythemename_page_process but didn't try that yet.
  • Unsetting the title variable may cause a php error, so I prefer not to unset the second variable too, it worked for me by just making it empty like the title.
  • I posted these solutions in drupal.org here for the welcome title and here for the default front page message.

Archive
Web
Linux