- Moderated by:
- Support Team
-
- rank:
-
Professional
- registered:
- December 2002
- Status:
- offline
- last visit:
- 24.08.08
- Posts:
- 1588
Greetings,
I think the personal messaging system in PostNuke is awesome, but does not stand out enough. Here is my solution embedd it in the theme, preferably somewhere noticeable like the header, maybe add a flashing animated gif or something?
You should be able to put this almost anywhere...
Code
//Please keep all comments intact :)
//This code is adapted from the PN messages module for inclusion in PN Themes.
//Function: display the amount of unread messages a user has and nothing if there are no new messages.
//Licence: GPL
//Adaptation by Adam Docherty (aka. Lobos) - www.webvida.com
//Make sure user is logged in
if (pnUserLoggedIn()) {
//This is the database hit
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$column = &$pntable['priv_msgs_column'];
$result2 = $dbconn->Execute("SELECT count(*) FROM $pntable[priv_msgs] WHERE $column[to_userid]=" . pnUserGetVar('uid')." AND $column[read_msg]='0'");
list($numrow) = $result2->fields;
$result2->Close();
//Now starts the output
echo "Welcome to $sitename <b>"
.pnUserGetVar("uname");
//This statement displays the amount of unread messages (or nothing if there are none)
if ($numrow == 0) {
echo"";
} else {
echo "</b> You have <a class=\"pn-normal\" href=\"modules.php?op=modload&name=Messages&file=index\"><b>".pnVarPrepForDisplay($numrow)."</b></a> ";
//This should be fairly self explainatory!
if ($numrow==1) {
echo "new message";
}
elseif ($numrow>1) {
echo "new messages";
}
echo"";
}
//This message will come up if no one is logged.
}else{
echo"Please register (or somthing...)";
}
//End of Adaptation by Adam Docherty (aka. Lobos)
Tried to display this with PHP bbcode, but it rendered the code illegiable.
Enjoy
Kindest regards
Lobos -
- rank:
-
Professional
- registered:
- December 2002
- Status:
- offline
- last visit:
- 24.08.08
- Posts:
- 1588
Greetings,
Add it to your theme.php in themes/yourtheme/theme.php (sometimes there are other files that are included by theme.php eg header.php).
And yes, PN 7.2.3.
Kindest regards
Lobos
--
-Lobos
Professional PHP Framework Services: Concept, Development and Deployment -
- rank:
-
Softmore
- registered:
- December 1969
- Status:
- offline
- last visit:
- 31.10.08
- Posts:
- 80
I put this in at TheBeachcats.com with a few small changes and it worked great. I think the site will get a lot more out of private messages now!
Damon
http://thebeachcats.com -
- rank:
-
Freshman
- registered:
- December 1969
- Status:
- offline
- last visit:
- 30.04.04
- Posts:
- 31
You can also add the URL to the following line so that the number of messages becomes a hyperlink to the private messages. That way the user doesn't need to scroll somewhere else to access private messages.
Code
echo " You have <a href=\"modules.php?op=modload&name=Messages&file=index\"><b>".pnVarPrepForDisplay($numrow)."</b></a> "; -
- rank:
-
Freshman
- registered:
- December 2002
- Status:
- offline
- last visit:
- 30.10.03
- Posts:
- 22
sorry I am new to PostNuke,
I have not seen this chat function you are talking about??
I have 2 sites with PostNuke
www.crusaderplanet.com // I'm an admin not creator of this site
www.gametoast.com // co creator, working on setting it up still, want to have a message function installed, from what I gather there already is one, and this makes it easier to see, how do I find it? -
- rank:
-
Freshman
- registered:
- May 2005
- Status:
- offline
- last visit:
- 09.04.06
- Posts:
- 26
thanks for the code!
here's what I did for my AutoTheme theme.
in 'modules\AutoTheme\includes\PostNuke\atCommands.php'
I edited:Code
$platformcmd['anonymous'] = array (
'user-links' => 'echo "<a href=\"user.php\">"._AT_NEWACCOUNT."</a> | '
.'<a href=\"user.php?op=loginscreen&module=NS-User\">"._LOGIN."</a>";',
'user-login' => 'echo "<form action=\"user.php\" method=\"post\">\n'
.' <span class=\"pn-normal\">"._NICKNAME."</span>\n'
.' <input type=\"text\" name=\"uname\" size=\"14\" maxlength=\"25\">\n'
.' <span class=\"pn-normal\">"._PASSWORD."</span>\n'
.' <input type=\"password\" name=\"pass\" size=\"14\" maxlength=\"20\">\n'
.' <input type=\"checkbox\" value=\"1\" name=\"rememberme\">\n'
.' <span class=\"pn-normal\">"._AT_REMEMBERME."</span>\n'
.' <input type=\"hidden\" name=\"module\" value=\"NS-User\">\n'
.' <input type=\"hidden\" name=\"op\" value=\"login\">\n'
.' <input type=\"hidden\" name=\"url\" value=\"index.php\">\n";'
.'$btn = "<input class=\"pn-button\" type=\"submit\" value=\""._LOGIN."\">\n";'
.'if (file_exists($imagepath."login.gif")) {'
.' $btn = "<input type=\"image\" src=\"".$imagepath."login.gif\" value=\""._LOGIN."\">\n";}'
.'elseif (file_exists($imagepath."login.jpg")) {'
.' $btn = "<input type=\"image\" src=\"".$imagepath."login.jpg\" value=\""._LOGIN."\">\n";}'
.'elseif (file_exists($imagepath."login.png")) {'
.' $btn = "<input type=\"image\" src=\"".$imagepath."login.png\" value=\""._LOGIN."\">\n";}'
.'echo $btn;'
.'echo "</form>\n";',
);
$platformcmd['loggedin'] = array (
'user-links' => 'echo "<a href=\"user.php\">"._AT_MYACCOUNT."</a> | '
.'<a href=\"user.php?module=NS-User&op=logout\">"._LOGOUT."</a>";',
);
to:Code
$platformcmd['anonymous'] = array (
'user-links' => 'echo "<a href=\"user.php\">"._AT_NEWACCOUNT."</a> | '
.'<a href=\"user.php?op=loginscreen&module=NS-User\">"._LOGIN."</a>";',
'user-login' => 'echo "<form action=\"user.php\" method=\"post\">\n'
.' <span class=\"pn-normal\">"._NICKNAME."</span>\n'
.' <input type=\"text\" name=\"uname\" size=\"14\" maxlength=\"25\">\n'
.' <span class=\"pn-normal\">"._PASSWORD."</span>\n'
.' <input type=\"password\" name=\"pass\" size=\"14\" maxlength=\"20\">\n'
.' <input type=\"checkbox\" value=\"1\" name=\"rememberme\">\n'
.' <span class=\"pn-normal\">"._AT_REMEMBERME."</span>\n'
.' <input type=\"hidden\" name=\"module\" value=\"NS-User\">\n'
.' <input type=\"hidden\" name=\"op\" value=\"login\">\n'
.' <input type=\"hidden\" name=\"url\" value=\"index.php\">\n";'
.'$btn = "<input class=\"pn-button\" type=\"submit\" value=\""._LOGIN."\">\n";'
.'if (file_exists($imagepath."login.gif")) {'
.' $btn = "<input type=\"image\" src=\"".$imagepath."login.gif\" value=\""._LOGIN."\">\n";}'
.'elseif (file_exists($imagepath."login.jpg")) {'
.' $btn = "<input type=\"image\" src=\"".$imagepath."login.jpg\" value=\""._LOGIN."\">\n";}'
.'elseif (file_exists($imagepath."login.png")) {'
.' $btn = "<input type=\"image\" src=\"".$imagepath."login.png\" value=\""._LOGIN."\">\n";}'
.'echo $btn;'
.'echo "</form>\n";',
);
// removed ("<a href=\"user.php\">"._AT_MYACCOUNT."</a>) from function below
$platformcmd['loggedin'] = array (
'user-links' => 'echo " | '
.'<a href=\"user.php?module=NS-User&op=logout\">"._LOGOUT."</a>";',
);
in 'themes\<theme>\theme.html' I edited the 'message-area' to:Code
<!-- message area start -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="{image-path}spacer.gif" width="1" height="5"></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#2A9DD7">
<tr>
<td width="3" height="3"><img src="{image-path}msg_tl.gif" width="3" height="3"></td>
<td height="3" colspan="2"><img src="{image-path}spacer.gif"></td>
<td width="3" height="3"><img src="{image-path}msg_tr.gif" width="3" height="3"></td>
</tr>
<tr>
<td><img src="{image-path}spacer.gif" width="1" height="1"></td>
<td valign="middle" class="headmsg"> <!-- [user-welcome] --> | <!-- [date] --> <!-- [time] --></td>
<td align="right" valign="middle" class="headmsg">
<?
//Please keep all comments intact :)
//This code is adapted from the PN messages module for inclusion in PN Themes.
//Function: display the amount of unread messages a user has and nothing if there are no new messages.
//Licence: GPL
//Adaptation by Adam Docherty (aka. Lobos) - www.webvida.com
//Make sure user is logged in
if (pnUserLoggedIn()) {
//This is the database hit
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$column = &$pntable['priv_msgs_column'];
$result2 = $dbconn->Execute("SELECT count(*) FROM $pntable[priv_msgs] WHERE $column[to_userid]=" . pnUserGetVar('uid')." AND $column[read_msg]='0'");
list($numrow) = $result2->fields;
$result2->Close();
//Now starts the output
//This statement displays the amount of unread messages (or nothing if there are none)
if ($numrow == 0) {
echo "<a href=\"user.php\">"._AT_MYACCOUNT."</a>";
} else {
echo "You have <a class=\"pn-normal\" href=\"modules.php?op=modload&name=Messages&file=index\"><b>".pnVarPrepForDisplay($numrow)."</b></a> ";
//This should be fairly self explainatory!
if ($numrow==1) {
echo "new message";
}
elseif ($numrow>1) {
echo "new messages";
}
echo"";
}
//This message will come up if no one is logged.
}
//End of Adaptation by Adam Docherty (aka. Lobos)
?>
<!-- [user-links] --> </td>
<td width="3"><img src="{image-path}spacer.gif" width="1" height="1"></td>
</tr>
<tr>
<td width="3" height="3" align="left" valign="bottom"><img src="{image-path}msg_bl.gif" width="3" height="3"></td>
<td height="3" colspan="2"><img src="{image-path}spacer.gif"></td>
<td width="3" height="3" align="right" valign="bottom"><img src="{image-path}msg_br.gif" width="3" height="3"></td>
</tr>
</table>
<!-- end message area -->
(some of the code is theme specific)
What this does is:
unregistered users see:
Register | Log-in (right side of 'message-area')
logged in registered user with no messages sees:
My Account | Log-out
logged in registered user with messages sees:
You have x messages | Log-out
thanks again :)</theme>
