TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,231
  • Total Topics: 21,353
  • Online today: 651
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 131
  • Total: 131

userbox: how do I add profile and logout links?

Started by ApplianceJunk, January 01, 2008, 03:59:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ApplianceJunk

I think it would be useful to have a profile and logout link included in the userbox.
How do I go about adding these links?

Thank you,
AJ

Edited to add:

1. If you have a URL, please post it.

http://www.ApplianceJunk.com

2. If you are getting an error message, copy it and paste it into your post. You can delete any privacy info, like usernames, etc., but try to keep as much of the error message intact as possible.

We are not getting any error messages at this time.


3. Let us know what version(s) you are using.
       
SMF 1.1.4/TinyPortal v0.9.8


4. Do you have any mods installed? If yes, tell us.

We have these mods installed.

1. SMF 1.1.2 Update Package 1.1.2
2. SMF 1.0.11 / 1.1.3 Update 1.1 
3. Ad Managment 2.3
4. Streaming 3 4.2.2b
5. nwsw.nwswAdminAttachAnything 1.1 RC3
6. SMF Sitemap 1.2.1
7. Users Online Today Mod 1.4.0
8. SMF Arcade 2.0.11
9. URL Popup 1.0
10. SMF Trader System 1.1 
11. SMF Classifieds Recent Classifieds Board Index 1.0 
12. TinyPortal 0.983 
13. SMF Gallery Pro 1.3beta3 
14. SMF Gallery Pro Upgrade 1.3
15. SMF 1.0.12 / 1.1.4 / 2.0 b1.1 Update 1.0 
16. Internal Links Use Same Window 1.1 
17. SMF Classifieds 1.1
18. Social Bookmarks 1.1
19. SSI Topic and Replies 0.1 
20. SMFBlog 0.1 Beta 
21. Treasury 2.04
22. Topic description 1.1

G6Cad

Can you please read our posting guide we have for this site and apply the proper changes to your post ?

ApplianceJunk

Quote from: G6 on January 01, 2008, 04:25:56 PM
Can you please read our posting guide we have for this site and apply the proper changes to your post ?

Yes I can, sorry about that.

I should have known better the first time.

Thank you,
AJ

IchBin

In the TPortal.template.php file you'll fine the function userbox() section in there. You can add a logout and profile button there. Take a look, and if you need help post back and I'll look at the file when I'm able to for you.

ApplianceJunk

In the attachment is the file.

I looked through it, but I am lost at this point.

I would like to put the links in this order.

PM:
Profile
Show unread
Show replies
Show own posts
Logout

It would be great if you could take a look at it when you get some time.

thanks,

IchBin

I'm sorry, I should have said TPortalBlocks.template.php file. :)

ApplianceJunk

No problem,

My TPortalBlocks.template.php is now attached.

I have been trying to make a logout link on the side and am not finding it so easy.

It would really be great if you could code it for me.



IchBin

Lets do this together so that you can learn some stuff. :) Here's the code for the userbox. Lets disect it a bit, and see if you can figure out how to add the links. I'll put comments about the code so you can see what its doing. :)
function TPortal_userbox()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
// The following bullet variables are created so we don't have to type out the image code where we want
// these images to be put in the rest of the code below.
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet3 = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet4 = '<img src="'.$settings['images_url'].'/tpgoto.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet5 = '<img src="'.$settings['images_url'].'/tpmodule2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
// start the box here :)
echo'
<div class="smalltext">';
// if the user's avatar is not empty AND TP's userbox avatar is set, echo the avatar image.
if (!empty($context['user']['avatar']) && isset($context['TPortal']['userbox']['avatar']))
echo $context['user']['avatar']['image'] . '<br />';

// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged']){
echo '<span class="normaltext">', $txt['hello_member'], ' <b>', $context['user']['name'], '</b></span>';

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm']){
echo '<br />'.$bullet.'<a href="', $scripturl, '?action=pm">' .$txt['tp-pm'].' ', $context['user']['messages'], '</a>';
if($context['user']['unread_messages']>0)
echo '<br />'.$bullet.'<a style="font-weight: bold; " href="', $scripturl, '?action=pm">' .$txt['tp-pm2'].' ',$context['user']['unread_messages'] , '</a>';
}
// Are there any members waiting for approval?
if (!empty($context['unapproved_members']))
echo '<br />'.$bullet.'<a href="', $scripturl, '?action=viewmembers;sa=browse;type=approve">'.$txt['tp_unapproved_members'].'<b> '. $context['unapproved_members']  . '</b></a>';
// the following lines display the unread/unread replies, and show own posts links.
if(isset($context['TPortal']['userbox']['unread'])){
echo '<br />'.$bullet.'<a href="', $scripturl, '?action=unread">' .$txt['tp-unread'].'</a>
<br />'.$bullet.'<a href="', $scripturl, '?action=unreadreplies">'.$txt['tp-replies'].'</a>
<br />'.$bullet.'<a href="', $scripturl, '?action=profile;u='.$context['user']['id'].';sa=showPosts">'.$txt['tp-showownposts'].'</a>';
}

// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '<br /><b>' .$bullet.$txt['tp_maintenace']. '</b>';
// Show the total time logged in?
if (!empty($context['user']['total_time_logged_in']) && isset($context['TPortal']['userbox']['logged'])){
echo '<br />'.$bullet.$txt['tp-loggedintime'] . ' ';
echo '<br />'.$context['user']['total_time_logged_in']['days'] . $txt['tp-acronymdays'];
echo $context['user']['total_time_logged_in']['hours'] . $txt['tp-acronymhours'];
echo $context['user']['total_time_logged_in']['minutes'] .$txt['tp-acronymminutes'];
}
if(isset($context['TPortal']['userbox']['time'])){
echo '<br />'.$bullet. $context['current_time'];
}
}
// Otherwise they're a guest - so politely ask them to register or login.
else{
echo '
', $txt['welcome_guest'], '<br />
', $context['current_time'], '<br />
<form action="', $scripturl, '?action=login2" method="post" >
<input type="text" name="user" size="10" /> <input type="password" name="passwrd" size="10" />
        <select name="cookielength">
<option value="60">', $txt['smf53'], '</option>
<option value="1440">', $txt['smf47'], '</option>
<option value="10080">', $txt['smf48'], '</option>
<option value="302400">', $txt['smf49'], '</option>
<option value="-1" selected="selected">', $txt['smf50'], '</option>
</select>
        <input type="submit" value="', $txt[34], '" /><br />
        ', $txt['smf52'], '
</form>';
}
echo '</div>';
}


Now to put a profile and logout link how can we do that? If you don't know what the link code would look like where can you look? Two places, you can get the link simply by copying the link from your browser window. (which you'll need to change a couple of things, but it will give you a start), OR you can look in another template file that already has the links for you. :) Let me know if you can't figure it out.

ApplianceJunk

QuoteLets do this together so that you can learn some stuff.

Sounds good to me. :)


QuoteOR you can look in another template file that already has the links for you.


Now why did I not think of that before? lol..


Just to see if I am on the right track first. This is what I found in the index.template.php file.

I am thinking it's what I need to use for the logout link, correct?


// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo'
<td align="center" class="menubg' , $current_action == 'logout' ? '2' : '' , '">
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>';

IchBin

That is exactly right on the code. Just remember you don't need the table code. All you need is the link code. :) Everything starting with the <a href to the ending < /a > tag.

This website is proudly hosted on Crocweb Cloud Website Hosting.