PHPBB : Add new variables to template code
Posted: Thu Apr 08, 2021 8:17 am
Add new variables to template code
/includes/functions.php
Find somewhere around line 4415:
example, make "user rank" as a template variable:
add it in:
also check out
https://wiki.phpbb.com/Queries_in_phpBB3
/includes/functions.php
Find somewhere around line 4415:
Code: Select all
// The following assigns all _common_ variables that may be used at any point in a template.
Code: Select all
$$userRank = "";
$sql="SELECT * FROM " . phpbb_users . " WHERE user_id = {$user->data['user_id']}";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$userRank = $row['user_rank'];
Code: Select all
// The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array(
'USER_RANK' => $userRank,
'SITENAME' => $config['sitename'],
'SITE_DESCRIPTION' => $config['site_desc'],
'PAGE_TITLE' => $page_title,
'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']),
'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit),
'LAST_VISIT_YOU' => $s_last_visit,
'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)),
'TOTAL_USERS_ONLINE' => $l_online_users,
'LOGGED_IN_USER_LIST' => $online_userlist,
'RECORD_USERS' => $l_online_record,
...
https://wiki.phpbb.com/Queries_in_phpBB3