Adding a "viewownprofile" mode for memberlist.php

Discussion forum for MOD Writers regarding MOD Development.
Locked
Tsuroerusu
Registered User
Posts: 12
Joined: Wed Dec 23, 2009 11:32 am

Adding a "viewownprofile" mode for memberlist.php

Post by Tsuroerusu » Tue Oct 08, 2013 7:34 pm

I have a phpBB forum that is heavily integrated with Joomla, and thanks to the RocketTheme template that I am using, i have a common menu in a very seamless manner by phpBB being able to use Joomla's menu.

What I want to do is put a menu item for a user's own profile, but in a different way than currently available mods (View Profile and View My Own Profile) do it.

Even in a pure Joomla site, the Joomla system has no way to put a username into a menu item, so I cannot use the "un=username" trick, as I have no way to get the username into the menu which would then pass the variable to phpBB. So what I would like to do is have add an additional mode, or an additional parameter for the current viewprofile mode of memberlist.php (Could be like "mode=viewprofile&own=yes", which would then make it assume that "u" is the user's own ID) that always assumes that the profile it is to display is that of the user him or herself.

Essentially, I would like a way to bring up a user's own profile that does not rely on variable input from the URL.

By having something like this, I could simply make a menu item that would say "My profile" and have the link be like:

/forum/memberlist.php?mode=viewownprofile
/forum/memberlist.php?mode=viewprofile&own=yes

That way the menu can be entirely static, and phpBB figures out which user to bring up internally, and does not need external input to do so.

Off the top of my head, what I could imagine doing is simply duplicating the code for the viewprofile mode in memberlist.php, and while that would be rather wasteful and overkill (Thus my suggestion of an "own=yes" variable) it would likely work, the only problem is that I have no idea how to make it assume the user id it is to query in the database is the user's own id.

Any help would be greatly appreciated.

User avatar
EXreaction
Former Team Member
Posts: 5666
Joined: Sun Aug 21, 2005 9:31 pm
Location: Wisconsin, U.S.
Name: Nathan

Re: Adding a "viewownprofile" mode for memberlist.php

Post by EXreaction » Thu Oct 10, 2013 3:30 pm

At the beginning of memberlist after $user->setup is called, and both $user_id and $mode are defined.

Code: Select all

if ($mode == 'viewownprofile')
{
    $mode = 'viewprofile';
    $user_id = (int) $user->data['user_id'];
}

Tsuroerusu
Registered User
Posts: 12
Joined: Wed Dec 23, 2009 11:32 am

Re: Adding a "viewownprofile" mode for memberlist.php

Post by Tsuroerusu » Sun Oct 13, 2013 1:44 am

EXreaction wrote:At the beginning of memberlist after $user->setup is called, and both $user_id and $mode are defined.

Code: Select all

if ($mode == 'viewownprofile')
{
    $mode = 'viewprofile';
    $user_id = (int) $user->data['user_id'];
}
You, sir, are an absolute hero of mine at this point! :D This works absolutely flawless, somebody, remind me to buy EXreaction a beer at some point. Thank you so much. :D

Anybody wanting a custom menu for their phpBB forum should consider applying this simple little modification. 8-)

User avatar
EXreaction
Former Team Member
Posts: 5666
Joined: Sun Aug 21, 2005 9:31 pm
Location: Wisconsin, U.S.
Name: Nathan

Re: Adding a "viewownprofile" mode for memberlist.php

Post by EXreaction » Mon Oct 14, 2013 1:43 pm

Not a problem. :)

Locked

Return to “[3.0.x] MOD Writers Discussion”