Hello,

I just want to modify the Drupal Status Messages of my node types like:

"Node type 1" has been created.

What the best aproach to do it?

What do I have to do for doing this with your module?

Thanks :)

Comments

BartonDrupal’s picture

Before getting started, I would make sure you're using the "recommended" release and not the "dev" release.

Now, the next module release (6.x-1.3) will contain more functions for pattern matching and searching the messages array. In the meantime, what you can do is something like this:

function yourcustommodule_message_alter(&$messages) {
    $matches = $messages->contains('has been created', 'status');
    $messages->remove($matches);
    $messages->add(t('Your new custom message'));
}

If you want to extract the node title and do something with it, try this:

function yourcustommodule_message_alter(&$messages) {
    $matches = $messages->contains('has been created', 'status');
    $messages->remove($matches); // NOTE: for this example I'm just going to get rid of all the messages that match
    if ($matches !== FALSE) {
        // NOTE: you might have more than one match, depending on what operation you do
        // for this example, I'm just going to assume you have 1 match
        $message = $matches['status'][0]['message'];
        if (preg_match('your_regex_here', $message, $match)){
            // TODO: do something with it
            // NOTE: $new_message is going to be your new message, after you've done stuff to it
            $messages->add(t($new_message), 'status');
        }
    }
}

If you're not a coder, you might want to wait until I have the UI working. No launch date as of yet :(

Let me know if you still have any questions or concerns.

Thanks,

Michael

Junro’s picture

Version: 6.x-1.x-dev » 6.x-1.2
Status: Active » Fixed

Ok, thanks for your help ^^

I will keep on eye on your module.

Until a new release with more funtionnalities, I will try your code.

Thanks :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.