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. GoogleGroups-like Drupal论坛
- 2. drupal:菜单中的论坛
- 3. phpBB3 - 创建论坛类别
- 4. 隐藏回复评论drupal的链接
- 5. Drupal 7:以编程方式创建论坛帖子
- 6. CSS /必要建立论坛式的消息
- 7. Moodle - 创建课程时无法创建新闻论坛
- 8. 隐藏NG-消息
- 9. Drupal 6:没有论坛索引页面(高级论坛)
- 10. Drupal - 在左侧显示论坛
- 11. 在Jekyll中创建标签或隐藏/取消隐藏内容?
- 12. 卡住创建论坛的答案表?
- 13. 隐藏的错误消息
- 14. 禁用Drupal内容创建消息?
- 15. 如何在vBulletin论坛上使用c#创建新主题?
- 16. 对论坛Drupal订阅的限制
- 17. Drupal中的动态论坛权限
- 18. 在论坛上张贴消息的不同形式
- 19. MySQL查询创建一个论坛
- 20. 隐藏jQuery验证消息
- 21. Drupal 7 - 论坛页面版主列表
- 22. 这是Drupal论坛模块吗?
- 23. Drupal 6隐藏修订信息
- 24. NoReverseMatch在/论坛/
- 25. nofollow在论坛?
- 26. 在java中隐藏警告消息
- 27. 论坛设计建议
- 28. React组件隐藏或重新创建?
- 29. Drupal在初始页面加载隐藏评论表格
- 30. 如何隐藏pander()中的消息?