我试图为每个用户显示每个单个标记的未读消息的数量。我创建了一条规则,自动标记一些新的威胁,使用来自模块Privatemsg过滤器7.x-2.0-alpha1 1的标记,允许用户使用标记或其他条件过滤消息。
我发现可以使用函数privatemsg_unread_count或添加查询,但这不能解决我的问题。
// Replace 'inbox' with 'sent' to display sent messages or 'list' to display all messages.
$query = _privatemsg_assemble_query('list', $user, 'inbox');我发现它很好用,但只显示未读消息,而不是按标签过滤。
0)
{ ?>还可以检查线程是否有带有privatemsg_rules_thread_has_tag的特定标记。
execute()->fetchCol();
if ($check_all) {
// If check_all is set, only return TRUE if all tags exist.
if (count(array_diff($tag_ids, $tag_ids_on_thread)) == 0) {
return TRUE;
}
}
else {
// If not, then it is enough it at least one of the submitted tags is used
// on the thread.
if (count(array_diff($tag_ids, $tag_ids_on_thread)) < count($tag_ids)) {
return TRUE;
}
}
return FALSE;
}
?>但有没有办法让它起作用。谢谢
发布于 2019-03-16 10:35:54
您可以使用
_privatemsg_assemble_query('unread_count', $account) 或privatemsg_unread_count($account = NULL) form privatemsg.module
功能医生。
/** *返回帐户未读消息的数量。** @param $account *指定应加载未读计数的用户。** @ingroup api */
发布于 2019-03-17 17:49:57
$count = _privatemsg_assemble_query('list', $user,'My_tags_name');
$unread = privatemsg_unread_count($count);
if($unread > 0)
{
echo ''.$unread. 'new messages';
} else {
}或
$query = _privatemsg_assemble_query('list', $user, 'inbox');
$total_count = db_result(db_query($query['count']));
echo $total_count;https://drupal.stackexchange.com/questions/277862
复制相似问题