Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By kabaman on
hi
how can i change drupal status messages ?
like "Your %post has been created" after an "add node" action
it comes from node.module line: 2266
function node_form_submit($form_id, $form_values) {
...
drupal_set_message(t('Your %post has been created.', array('%post' => node_get_types('name', $node))));
...
thanks in advance
Comments
The clean but cumbersome
The clean but cumbersome method is to enable the locale module, add a new language, call it for example "Custom Language", make it the default, find the strings you want in the locale page and "translate" them.
The quick and dirty method is of course to hack the string you found directly in the module file.
Or do you mean something else?
Hello, How would you change
Hello,
How would you change this message for only one node type?
Something in the template.tpl file?
Thanks
Paul
Confirm solution for your problem
check http://drupal.org/node/236729
Can't access your
Can't access your link:
check http://drupal.org/node/236729
modify the SESSION 'messages' variable in a theme function
I've removed and modified Drupal messages by searching the sessions variable for the string and removing it. Here's my custom function from my template.php file.
Once you have this, you can call it from a theme function that overrides theme_status_messages
(where [themeName] is the name of your theme.)
My first example removes the status message set by the user module when a user registers, the second function call replaces the message with a new string.
It may be tricky, though, to remove a string that has dynamic text (like %type, etc.). The best way may be to use preg_match to find it, or exclude all possible variants. Please reply to this post to tell me where this may not be right, but it seems to work for me so far.
Tried it and it works
I wanted to modify the message sent by the node module when a node was created using the hook_nodeapi however the node module sets its message after the hook is called so you can't remove it. I tried the script, it works good. I used the strripos php to search for substrings when I have %type and so on.
could you elaborate on your
could you elaborate on your strripos method, I'd like to change the 'your @type %title has been created' message on just one type of node.
did you ever figure this out?
did you ever figure this out? I'm trying to do the same thing.
A few updates to your function
This function is great and works in Drupal 6 as well, however I made a couple small changes. For some reason, and this may be a Drupal 6 specific problem, when key 0 of the array is removed if there are other messages in the array they will not be displayed. This was fixed by resorting the array after removal. I added a line to remove the entire messages array when all messages have been removed to keep the message from displaying a blank box.
Also, I added a search feature so you don't need to match the exact message, this should help with dynamic text as well.
Updated _exclude_message() function:
Thanks!
So how would this work for a
So how would this work for a specific node type and dynamic text?
Here a nice little module to
Here a nice little module to custom status messages.
Custom Submit Messages module
Here the drupal way of doing
Here the drupal way of doing it http://www.deeson.co.uk/online/labs/overwriting-the-node-has-been-create...