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查询创建一个论坛