Do you mean unread posts?
I use this below:
function:call it:html it:If not, phpBB has predefined template vars for PMs and notifications/ counts these may contain "messages"
//edit-- fixed permissions when not in custom search page
Hope this helps![Wink ;)]()
I use this below:
function:
Code:
public function count_unread_posts(): self|false{if ($this->user->data['is_bot'] or $this->user->data['user_id'] == ANONYMOUS or !$this->auth->acl_get('u_search') or empty($this->config['load_search'])){return false;}$count = (int) 0;$sql = 'SELECT forum_idFROM ' . FORUMS_TABLE . ' WHERE ' . $this->db->sql_in_set('forum_id', array_keys($this->auth->acl_getf('f_read', true)), false);$result = $this->db->sql_query($sql);$forum_ids = [];while ($row = $this->db->sql_fetchrow($result)){if (!$this->auth->acl_getf('f_read', $row['forum_id'])){continue;}$forum_ids[] = (int) $row['forum_id'];}$this->db->sql_freeresult($result);if (!empty($forum_ids)){$sql_where = 'AND ' . $this->db->sql_in_set('t.forum_id', $forum_ids, false);$id_ary = get_unread_topics($this->user->data['user_id'], $sql_where, '', 99999);$count = count($id_ary);}$this->template->assign_vars(['SHOW_COUNT_SEARCH_UNREAD' => $this->language->lang('SEARCH_UNREAD') . ' ' . $count,]);return $this;}Code:
$this->count_unread_posts();Code:
{% if SHOW_COUNT_SEARCH_UNREAD %}{# or my message to be show #}<a href="{U_SEARCH_UNREAD}">{{ SHOW_COUNT_SEARCH_UNREAD }}</a>{% endif %}Code:
{{ NOTIFICATIONS_COUNT }}{{ UNREAD_NOTIFICATIONS_COUNT }}{{ PRIVATE_MESSAGE_COUNT }}Hope this helps
Statistics: Posted by Steve — Sun Jun 22, 2025 7:22 am