API を使用して新しいフォーラムを作成するたびに、次のメッセージが表示されます。
新しいフォーラムを何とか作成しました
表示されます(ステータス メッセージ)。
抑えることはできますか?もしかしてフック付き?
API を使用して新しいフォーラムを作成するたびに、次のメッセージが表示されます。
新しいフォーラムを何とか作成しました
表示されます(ステータス メッセージ)。
抑えることはできますか?もしかしてフック付き?
Disable Messagesモジュールを使用して、プログラムを使用せずにこれを行うことができます。
在庫メッセージを抑制するのは面倒ですが、それは可能です。「function template_preprocess_page(&$variables)」を作成するのが良い方法だと確信しています
テーマでそれを設定し、$variables で print_r を実行します。ページに表示されようとしているすべてのメッセージがその配列のどこかで利用可能になると確信しており、ページテンプレートまで作成したくないメッセージの設定を解除することができます.
メッセージを変更するために使用できるフックを作成するモジュールがあります。http://drupal.org/project/messages_alter
あなたのユースケースではうまくいくと思いますが、提供されていないものが必要な場合、または独自のオプションを展開したい場合: モジュールをざっと見てみると、独自の実装を作成する方法についてのアイデアが得られます。それが必要。
モジュールを使用する代わりに、なぜ自分たちでそれを行ったのか正直思い出せませんが、ここにいくつかの非常に単純なコード例を示します。
/**
* function to check the messages for certian things and alter or remove thme.
* @param $messages - array containing the messages.
*/
function itrader_check_messages(&$messages){
global $user;
foreach($messages as &$display){
foreach($display as $key => &$message){
// this is where you'd put any logic for messages.
if ($message == 'A validation e-mail has been sent to your e-mail address. In order to gain full access to the site, you will need to follow the instructions in that message.'){
unset($display[$key]);
}
if (stristr($message, 'processed in about')){
unset($display[$key]);
}
}
}
// we are unsetting any messages that have had all their members removed.
// also we are making sure that the messages are indexed starting from 0
foreach($messages as $key => &$display){
$display = array_values($display);
if (count($display) == 0){
unset($messages[$key]);
}
}
return $messages;
}
テーマ機能:
/**
* Theme function to intercept messages and replace some with our own.
*/
function mytheme_status_messages($display = NULL) {
$output = '';
$all_messages = drupal_get_messages($display);
itrader_check_messages($all_messages);
foreach ($all_messages as $type => $messages) {
$output .= "<div class=\"messages $type\">\n";
if (count($messages) > 1) {
$output .= " <ul>\n";
foreach ($messages as $message) {
$output .= ' <li>'. $message ."</li>\n";
}
$output .= " </ul>\n";
}
else {
$output .= $messages[0];
}
$output .= "</div>\n";
}
return $output;
}