1

I need to show some message for user for every page at my site.

I've tried Rules action "Content is viewed" and I see message, but only when some node is displayed.
I don't see message when I open User page, or page with Taxonomy term, or some View page without nodes as content.

How can I show message at every page of my site regardless page content? (Rules or Hooks or ...?)

3 Answers 3

1

Why not to write it directly in the template? Or create a Block which you show in the header? or do you need to use the drupal_set_message() Message?

You can use "Drupal is initializing" event at Rules.

3
  • I plan to use drupal_set_message() as standard. I'll try use hook_init() as @wolverine said
    – Dimetry
    Commented Jun 27, 2014 at 12:45
  • OK, there is also a rule for "Drupal is initializing". Maybe you can use this so you can configure it instead of coding it.
    – Lance
    Commented Jun 27, 2014 at 12:54
  • "Drupal is initializing" works well. I can't find when this event triggers. But I suspect it's equal hook_init(). ty
    – Dimetry
    Commented Jun 27, 2014 at 13:15
0

Implement hook_init() and set the message using drupal_set_message(). But as @lance asked, why can't you put it in to template?

Note : make sure you set $repeat = FALSE while using drupal_set_message()

0

You can easily do this by simply write

drupal_set_message('Message That You want To display');

this into your activated theme page.tpl.php .That message will be shown for every page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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