In Drupal, there several ways to display static message on the pages i,e via blocks and placing into specific region or via code; adding dsm on hook_init() etc. In this article we will try to display static message on all the pages via rules.
1) Initially we will create an event name called "Display banner on page load" and event will be "Drupal is initializing".
2) There is no need to add an conditions as we want to display this banner message in all the pages.
3) Then lets create an actions: Add an action "Show a message on the site" under system and add banner message text value. You can also set the "Message type" and make sure you select "Repeat message: False." or else the message might displayed multiple times.
Thats it. Check the functionality it works like charm.
{ "rules_display_banner_on_page_load" : {
"LABEL" : "Display banner on page load",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "init" : [] },
"DO" : [
{ "drupal_message" : {
"message" : "\u003Cb style=\u0022color:#1BA6DF\u0022\u003EBanner Message\u003C\/b\u003E.",
"repeat" : "0"
}
}
]
}
}