2011-06-07, 07:19 AM
I'm trying to add a new navigation item to the usercp_nav template area and have so far got this code:
In the actual template, the code is virtually unchanged, except I've added {$changeuserpage} (obviously).
The problem is, I can echo out $changeuserpage and it is echoed at the top of the page fine. However, it is not displayed in the page via the template when you view it. I have no idea why this should be as I've checked and the usercp_nav template is definitely built after the hook I'm using.
If anybody's got any idea, I'd love to have it
Actually, nevermind. I found a fix. The code to do it (if anybody wants it) is as follows:
$plugins->add_hook("usercp_menu", "userpages_usercpmenu");
function userpages_usercpmenu()
{
global $mybb, $cahce, $lang, $changeuserpage;
require_once MYBB_ROOT."/inc/class_datacache.php";
$cache = new datacache;
$cache->cache();
$usergroups_cache = $cache->read("usergroups");
$lang->load("userpages");
echo $lang->changeuserpage;
if ($usergroups_cache[$mybb->user['usergroup']]['canuserpage'] && $usergroups_cache[$mybb->user['usergroup']]['canuserpageedit']) {
$changeuserpage = '<tr>
<td class="trow1">
<div><a href="usercp.php?action=edituserpage" class="usercp_nav_item usercp_nav_profile">'.$lang->changeuserpage.'</a></div>
</td>
</tr>';
}
}
In the actual template, the code is virtually unchanged, except I've added {$changeuserpage} (obviously).
The problem is, I can echo out $changeuserpage and it is echoed at the top of the page fine. However, it is not displayed in the page via the template when you view it. I have no idea why this should be as I've checked and the usercp_nav template is definitely built after the hook I'm using.
If anybody's got any idea, I'd love to have it
Actually, nevermind. I found a fix. The code to do it (if anybody wants it) is as follows:
$plugins->add_hook("usercp_menu", "userpages_usercpmenu");
function userpages_usercpmenu()
{
global $db, $mybb, $templates, $theme, $usercpmenu, $lang, $collapsed, $collapsedimg, $lang, $cache;
require_once MYBB_ROOT."/inc/class_datacache.php";
$cache = new datacache;
$cache->cache();
$usergroups_cache = $cache->read("usergroups");
$lang->load("userpages");
if ($usergroups_cache[$mybb->user['usergroup']]['canuserpage'] && $usergroups_cache[$mybb->user['usergroup']]['canuserpageedit']) {
eval("\$usercpmenu .= \"".$templates->get("usercp_nav_userpages")."\";");
}
}