1
A
回答
0
有一個模塊可以創建一個可以用來更改消息的鉤子。 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;
}
0
抑制股票消息是一種痛苦,但它可以完成。我很確定一個好方法是使'function template_preprocess_page(& $ variables)'
在你的主題中設置它,並在$變量上執行print_r。我非常肯定,即將在頁面上呈現的所有消息都將在該數組中的某個位置可用,並且您可以取消那些不想讓它一直到頁面模板的消息。
1
你可以通過使用Disable Messages模塊
做到這一點非編程相關問題
- 1. 隱藏鏈接在論壇
- 2. GoogleGroups-like Drupal論壇
- 3. drupal:菜單中的論壇
- 4. phpBB3 - 創建論壇類別
- 5. 論壇創建或生成
- 6. 將Ning論壇的內容遷移到Drupal論壇?
- 7. 隱藏回覆評論drupal的鏈接
- 8. 如何創建Drupal論壇報告/分析視圖?
- 9. Drupal 7:以編程方式創建論壇帖子
- 10. CSS /必要建立論壇式的消息
- 11. Moodle - 創建課程時無法創建新聞論壇
- 12. 隱藏NG-消息
- 13. Drupal 6:沒有論壇索引頁面(高級論壇)
- 14. 隱藏在Drupal
- 15. Drupal - 在左側顯示論壇
- 16. 如何在greasemonkey中創建隱藏/取消隱藏按鈕
- 17. 在Jekyll中創建標籤或隱藏/取消隱藏內容?
- 18. 卡住創建論壇的答案表?
- 19. 試圖創建的MyBB論壇
- 20. 隱藏的錯誤消息
- 21. 禁用Drupal內容創建消息?
- 22. Drupal論壇的高級搜索模塊
- 23. Drupal的論壇主題鎖定
- 24. 對論壇Drupal訂閱的限制
- 25. Drupal中的動態論壇權限
- 26. 如何在vBulletin論壇上使用c#創建新主題?
- 27. 使用Drupal API計算髮布在Drupal論壇的線程數
- 28. 在asp.net中的論壇消息線程MVC
- 29. 在論壇上張貼消息的不同形式
- 30. MySQL查詢創建一個論壇