Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
A tasty little morsel for themers
  • Posted: 18.01.2003, 08:44
     
    Lobos
    rank:
    Professional 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&nbsp;<b>"
    .pnUserGetVar("uname");

    //This statement displays the amount of unread messages (or nothing if there are none)
    if ($numrow == 0) {
                 echo"";
    } else {
                 echo "</b>&nbspYou have&nbsp<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 o­ne 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
  • Posted: 20.01.2003, 08:36
     
    vogelap
    rank:
    Freshman Freshman
    registered:
     December 1969
    Status:
    offline
    last visit:
    25.03.03
    Posts:
    3
    In which file are these edits made? Are you using 0723 as source?
  • Posted: 20.01.2003, 17:08
     
    Lobos
    rank:
    Professional 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
  • Posted: 20.01.2003, 17:45
     
    damon
    rank:
    Softmore 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
  • Posted: 20.01.2003, 21:33
     
    Lobos
    rank:
    Professional Professional
    registered:
     December 2002
    Status:
    offline
    last visit:
    24.08.08
    Posts:
    1588
    Good for you damon!

    --
    -Lobos
    Professional PHP Framework Services: Concept, Development and Deployment
  • Posted: 14.03.2003, 01:41
     
    pcmodeler
    rank:
    Freshman 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 "&nbspYou have&nbsp<a href=\"modules.php?op=modload&name=Messages&file=index\"><b>".pnVarPrepForDisplay($numrow)."</b></a> ";
  • Posted: 18.03.2003, 03:54
     
    Lobos
    rank:
    Professional Professional
    registered:
     December 2002
    Status:
    offline
    last visit:
    24.08.08
    Posts:
    1588
    If you look closely you find that this is already the case - the links are active eg -Lobos
    Professional PHP Framework Services: Concept, Development and Deployment
  • Posted: 04.05.2003, 05:31
     
    deRusett
    rank:
    Freshman 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?
  • Posted: 05.05.2003, 02:14
     
    mhalbrook
    rank:
    Legend Legend
    registered:
     December 1969
    Status:
    offline
    last visit:
    21.11.08
    Posts:
    6517
    Nice idea, That should be a function added to PN to allow just a call to displaypm(); in the theme :) Or am I over simplifying the matter? :)
  • Posted: 30.06.2005, 21:35
     
    AuntieSocial
    rank:
    Freshman 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">&nbsp;&nbsp;<!-- [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&nbsp;<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 o­ne is logged.
    }
    //End of Adaptation by Adam Docherty (aka. Lobos)

    ?>


    <!-- [user-links] -->&nbsp;&nbsp;</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>

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula