Welcome Message Welcome Message
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Welcome Message

Started by Andy Frogman, August 13, 2011, 08:29:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy Frogman

I've done some very rigorous searching throughout the forum, however I've not been able to find an answer to this question, as similar as it may seem to others.

I want to add a welcome message, simply these two messages:

Guest User: "Welcome Guest!"
Registered User: "Welcome back, [username]!"

Now, simply manipulating the theme.php file I have been able to make the welcome messages change, however my problem is, I can't get the user name to display. I have a pair of screen shots here that demonstrate this. (Please note this is still under development.)

http://storage.ultima-java.com/frogman/misc/coppermine/loggedin.png

http://storage.ultima-java.com/frogman/misc/coppermine/loggedout.png

I need that [username] tag to actually become a the members user name. I know it's possible, because there is already a call for the username on the "logout" link.


Αndré

The current user ID is always stored in the constant USER_ID. You can use it to get the user name from the database.

Andy Frogman

It won't show... This is my code:

<!-- BEGIN contact -->
<tr>
<td align="center" colspan="2" style="font-size: 11px;">
Welcome back, {USER_ID}!
</td>
</tr>
<tr>
<td align="left" width="20px">
<img src="themes/creative_ver0.1/images/icon_mini_message.gif" border="0" />
</td>
<td align="right" style="font-size: 11px;">
<a href="{CONTACT_TGT}" title="{CONTACT_TITLE}"><span>{CONTACT_LNK}</span></a>
</td>
</tr>
<!-- END contact -->

Αndré

That's not the way how it works. If you add a new token (that's what you did actually), you need to replace it within the function theme_main_menu in your theme.php file. Use something like
$cpg_udb->get_user_name(USER_ID)
or grab the user name with your own SQL query. The user ID stored in the constant USER_ID is just a number, not the user name.

Andy Frogman

I'm sorry, could you explain that a bit better, I don't quite grasp what your saying. This is what I think you are telling me:

I can see that I've done something wrong and in order to get my token {USER_ID} or whatever I want it to be, to work, I have to add

$cpg_udb->get_user_name(USER_ID)

into the theme.php file. In order to do this I have to copy the data from themes.inc.php that deals with the main menu functions.

I imagine that is the one labelled "**Section <<<theme_main_menu>>> - START".

So where in this file do I then place the new code? Or have I misunderstood you?

Αndré

Quote from: Andy Frogman on August 15, 2011, 04:45:09 PM
So where in this file do I then place the new code?
It doesn't matter as long you put it somewhere between
<?php
and
?>


I don't know how your theme looks like nor what you've already modified. If you need further assistance please attach your theme as zip file to your next reply.

Andy Frogman

Ah that's a good point :P I haven't really made any major mods, and though the appearance has changed drastically, it's based off the Water Drop theme. It's still got a lot of work to go on it.

is .rar ok?

Αndré

Please use the zip format if possible (it's much more compatible than rar).

Andy Frogman

It's all good, I just had a .rar file already uploaded.

Here it is: http://storage.ultima-java.com/frogman/misc/creative_ver0.1.zip

Αndré

Use the version which is attached to this post.

Andy Frogman

Thanks very much. I appreciate that!

I can see what you've done here, would it be the same process to call the Avatar from the phpBB3.x forums? Or will that require a totally new query?

Αndré

I doubt that a function exists that get the avatar from the database, but I simply don't know. Have a look at the appropriate bridge file. If not, you have to query the database to get the user avatar path.

Andy Frogman