MyBB Community Forums

Full Version: {$lang->welcome_back}
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I think this topic should be moved to the mods section.
Hi.

I am trying to create a second version of the {$lang->welcome_back} variable.

In global.lang.php, I find the line of code that said:
$l['welcome_back'] = "<strong>Welcome back, {1}</strong>. You last visited: {2}";


However, I'm trying to make

$l['welcome_back'] = "<strong>Welcome back, {1}</strong>. You last visited: {2}";
$l['welcome_backtest'] = "You last visited: {1}";

I am basically cutting the word Welcome back from the variable, and I replaced the {2} at the end of last visited with {1}. I'm still trying to get the same fuction as before, but it won't work. Instead of displaying time it says: You last visited: %1$s . How do I fix this so it displays the time you last visited, not just numbers and symbols? Is there another file that I need to edit the #1 for $l['welcome_backtest'] ?

Oh, and no, I cannot just edit $l['welcome_back'] = "<strong>Welcome back, {1}</strong>. You last visited: {2}"; becuase I need it for two diffrent things.
Yes, you have to edit global.php (assuming you want it globally).

You'll need to sprintf the variable, otherwise, {1} makes no sense.

In global.php, find:
$lang->welcome_back = sprintf($lang->welcome_back, $mybb->user['username'], $lastvisit);
After, add:
$lang->welcome_backtest = sprintf($lang->welcome_backtest, $lastvisit);
Thanks for you help. It worked.
I am trying to accomplish the same thing again, however, this time the line of code in global.lang.php
$l['welcome_back'] = "<strong>Logged in as: {1}</strong>.";
$l['welcome_last'] = "<strong>Welcome back;</strong> You last visited: {1} ";
This time, the varible for {1} in the $l['welcome_back'] is the username. I am having no trouble with that. However, when I try making the variable {1} for $l['welcome_last'], I get the same problem I got last time, with the forum saying: You last visited: %1$s . So, In went to global.php in the main folder for the forum, and added the line of code
$lang->welcome_last = sprintf($lang->welcome_last, $lastvisit);
under
$lang->welcome_back = sprintf($lang->welcome_back, $mybb->user['username'], $lastvisit); 
. However, when i upload global.php to my site, and when I try load the page for the forums, the forum does not show up. It is my understanding that the only files that I needed to edit where global.lang.php in uploads/inc/languages/english/ and global.php in the uploads folder. Also, i don't need to edit anything in the Admin Control Panel. I also deleted the line of code:
$lang->welcome_back = sprintf($lang->welcome_back, $mybb->user['username'], $lastvisit); 
, but I still get the same error. Please tell me what I'm doing wrong - possibly a typo?
Make sure you're not editing the files in Notepad (use another program like WordPad, Crimson Editor, Notepad++, EditPlus, etc).

Also, please upload your .php files in Text/ASCII mode in your FTP client (consult your FTP client documentation/support for details)
Another problem has arisen. When you are a guest, it displays "%1$s", instead to the time you last visited the site. What I would like to do is make it so that it just displays the current time, for there is no way you can track previous sessions from the guest. Should this post be moved to the modifications area?
redbear81 Wrote:Another problem has arisen. When you are a guest, it displays "%1$s", instead to the time you last visited the site. What I would like to do is make it so that it just displays the current time, for there is no way you can track previous sessions from the guest. Should this post be moved to the modifications area?
Use the {$datenow} and {$timenow} variables, for example, you may put this in a template:
Welcome back - you last visited {$datenow}, {$timenow}
ZiNgA BuRgA Wrote:
redbear81 Wrote:Another problem has arisen. When you are a guest, it displays "%1$s", instead to the time you last visited the site. What I would like to do is make it so that it just displays the current time, for there is no way you can track previous sessions from the guest. Should this post be moved to the modifications area?
Use the {$datenow} and {$timenow} variables, for example, you may put this in a template:
Welcome back - you last visited {$datenow}, {$timenow}
How do I apply this only to the guest? If I apply it to the template, it will apply for all users, since the script is on the index template. I can move the it the header, but still, it would apply to all users. I cannot put it in the guest header template, for its postion on the page will not be correct. Is it possible for mybb to search and see if the current vistor is logged in, and if not, display the {$datenow}, {$timenow}? Such as an "else" or and "if else" statment, in the global.php file?
In global.php, find:
eval("\$header = \"".$templates->get("header")."\";");
Before that line, add:
$welcome_line = '';
if($mybb->user['uid'])
{
    $welcome_line = "your welcome text";
}