4

I have a front page in which blocks and some contents (ie story) were displayed. These stories were marked as "Promoted to front page"; later, I unchecked them. These stories are now gone, yet the blocks were present.

Now I have the following content on my front page:

"No front page content has been created yet.

Add new content"

How do I remove this content or text?

8

Just add this code to the page.tpl.php or page--front.tpl.php on Drupal 7.

find

<?php print render($page['content']); ?>

and replace with below code.

<?php  if(drupal_is_front_page())
                {
                    unset($page['content']['system_main']['default_message']);
            } 
        print render($page['content']); 
    ?>

And i believe you surely get all blocks or contents you posted on page.

and to remove page title on page like

Welcome to "website name"

find this code on page.tpl.php or page--front.tpl.php

<?php if ($title): ?><h1 class="title" id="page-title"><?php  print $title; ?></h1>
<?php endif; ?>

and you can remove this code or else just make a comment over.

  • Depending on other parts of your site, it is possible that $page['content']['system_main']['default_message'] is not set, in which case the unset() call in your code example will throw an error. This is also not the best solution. Seeing as the person has said they are not using the default home page functionality it makes more sense to use a different page as the home page. – rooby Feb 2 '13 at 1:25
1

There are a couple of ways in which you can accomplish this:

  1. Front Page

  2. Views

If you go the views route, enable the frontpage view, then go to admin/config/system/site-information and change the "Default front page" path to 'frontpage.'

0

First create one sample page using node/add/page in admin side of your website.

After creating the page, you can set the homepage of your website using admin/config/system/site-information of your website. there you need to paste the url of your previously created page path in "Default front page" textbox. After saving the configuration, the home page content will be replaced with your new page content.

Hope this can work for you!

  • If the main home page content is not actually going to be the body of this node it is not the best idea to do it this way, because resources are used loading the node for no reason, plus in this case the home page is not actually intended to be a node, but just a collection of blocks. – rooby Feb 2 '13 at 1:22
0

Out of the three ways above, which is the best way and guaranteed to work for drupal 7 bartik and zen themes?

  • The empty_page module solution will work with any theme. – rooby Feb 2 '13 at 1:22
0

If you just want a bunch of blocks on the home page (a very common requirement), the best easy way to do this is to use the empty_page module.

To use it you can:

  1. Create an empty page (via the settings page of the module) with the path "home" (or similar) and the title being the name of your site (unless you want some other title for the home page).
  2. On the site information settings page (admin/config/system/site-information), set the home page path to "home" (or whatever you made the path in the previous step).

This approach is good because you are not loading a node unnecessarily (in the case you use a blank node page as your home page) or processing the default drupal home page code, which is good for performance, and the module is simpler than the front page module.

0

The D7 main content is now a block, so just set the Main page content under blocks settings. Go to Structure > Blocks > Click configure on Main page content. On "Show block on specific pages" choose "All pages except those listed" and fill with <front>.

Source.

-1

Just edit to /modules/node/node.module, look for $default_message line (around line 2621) and change 'No front page content has been created yet' to simply ''.

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