0
votes

I use my custom block for displaying a flash game at the front page of my Drupal 7 installation, but there is also the annoying message:

<div id="first-time"><p>No front page content has been created yet.</p>
<div class="item-list"><ul><li class="first last">
<a href="/node/add">Add new content</a></li> 
</ul></div></div>

below it and I can't remove it. Is there please a hook for adding custom CSS? In my module I would like to make the #first-time light grey or invisible.

I prefer not to add a blank content just to get rid of that text.

Thank you! Alex

UPDATE:

I've added the following to my module:

function game_init() {
  drupal_set_message('XXX init called XXX');
  if (drupal_is_front_page()) {
    drupal_add_css('#first-time {color: green;}', 'inline');
  }
}

but don't see that CSS-code or XXX string inside my front page.

UPDATE2:

Oh, I had to clear the cache and now it works (the Drupal docs seem to be wrong here - there was written that 'inline' CSS is not cached...)

3

3 Answers

3
votes

Hiding the CSS is the WRONG way of doing it. why did you created your content as a Custom Block?

  • you should create a "Page" and set this page as front page in the Configuration->Site Information.

Whatever. you can also use any of these options but is not recommended.

  • you can also also add a BlankPage by Adding only the Title(then hiding it in PHP on page.tpl.php)
  • you can add your css in /templates/themes/bartik.info
  • you can call drupal_add_css on the _init() hook of your custom module.

Blocks are used to display information in every page(although we can set to display only on certain pages). Say For Example. A Menu, or A Shopping Cart etc.

1
votes

If you want to add some CSS for a module, you should use drupal_add_css()

0
votes

Why not simply add this CSS to your theme?