An adequate solution to this problem:
<?php
function gen_links()
{
global $phpbb_root_path, $phpEx, $template, $user;
$user->add_lang(‘mods/links’);
$template->assign_vars(array(
‘U_NEW_LINK’ => append_sid(“{$phpbb_root_path}link.$phpEx”)
));
}
$phpbb_hook->register(array(‘template’, ‘display’), ‘gen_links’);
?>
Of this whole venegret, you need to change the line 'U_NEW_LINK' => append_sid("{$phpbb_root_path}link.$phpEx")
, где U_NEW_LINK
– variable name, and append_sid
– is a function that returns a string containing the URL with the session ID.
If you want to insert a link to an internal page, such as a topic (I made a link to the rules of the forum), this line will look something like this:
‘U_NEW_PRAVILA’ => append_sid($phpbb_root_path.’viewtopic.’.$phpEx, ‘f=21&t=41’)
If you want to insert an external link, use this construction:
‘U_NEW_PRAVILA’ => append_sid(“http://google.com/”)
2) Now we need to create a language file, in which we will write the text of the links. Use the folder language/en/mods , where we create links.php with the following contents:
<?php
$lang = array_merge($lang, array(
‘NEW_LINK’ => ‘Click me’
));
?>
In my case, I was referencing forum rules, so the variable looked like this:
‘NEW_PRAVILA’ => ‘Forum rules’
3) Now use our variables in the template file overall_header.html. This is easy to do in the admin panel: Styles – Templates – Change and select our file.
<li><a href=”{U_NEW_PRAVILA}”>{L_NEW_PRAVILA}</a></li>
For the li tag, you can specify the class=”…” property, where you can insert an icon, such as icon-subscribe, instead of a triplet.
4) Now clear the cache (you can do it on the main admin page), and you will see your coveted button in phpBB (smiley)