Fork me on GitHub

Watch

GitHub Core

Show your support for Zikula! Sign up at Github account and watch the Core project!




GitHub Modules

Forum Activity

Forum feed

» Visit forum | » View latest posts

Add 'You have 2 new messages(s)  Bottom

  • Hi, I'm begining to learn some of the basics in taking an existing theme, and adding some modifiations to it.

    So far, I'v managed to add this into my theme, so it will Say "Welcome back Switch17, and provide a link to your account.

    But I want to continue it a little further, and have it say 'Welcome back Switch17, you have 2 new message(s). Now of course the number of messages would vary.

    Here's the code I have right now:

    Code

    <?
    if (pnUserLoggedIn()) {
    echo "Welcome Back $username - <a href=\"user.php\">Your Account</a> | <a href=\"user.php?module=NS-User&op=logout\">Logout</a></td>";
    } else {
    echo "<form action=\"user.php\" method=\"post\"><a href=\"user.php\">Create an Account</a> :: Username <input type=\"text\" name=\"uname\" size=\"10\" maxlength=\"50\"> Password <input type=\"password\" name=\"pass\" size=\"10\" maxlength=\"25\"><input type=\"checkbox\" value=\"1\" name=\"rememberme\" /> Remember me  <input type=\"hidden\" name=\"module\" value=\"NS-User\" /><input type=\"hidden\" name=\"op\" value=\"login\" /><input type=\"hidden\" name=\"url\" value=\"index.php\"><input type=\"submit\" value=\"Login\"></td></form>";
    }
    ?>


    One other thing I may want to do as well is perhaps have it say "Welcome back Switch17, you last visited on XXXXX?

    Can anyone give some pointers as to how I would continue in editing the code for this?

    Thanks
    Switch
  • Greetings,

    I have taken this from my wvHarmonyX theme.

    Code

    <?php
       
        if (pnSecAuthAction(1, '.*', '.*', ACCESS_ADMIN)) {
         echo "<font class=\"wvLoginBar\">\n";
         echo "&nbsp;&nbsp;[<a href=\"admin.php\">Admin Menu</a>]&nbsp";
         }
        if (pnUserLoggedIn()) {
            $username = pnUserGetVar('uname');
        echo "&nbsp;&nbsp;<font class=\"pn-normal2\">\n";
        echo "<font class=\"pn-normal2\">"._WELCOME.$username."!&nbsp;&nbsp;<a href=\"user.php\">My Account</a>&nbsp;|\n"
        ."<a href=\"user.php?module=NS-User&op=logout\">Logout</a>&nbsp;&nbsp;&nbsp;\n";

            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'));

            list($numrow) = $result2->fields;
            if ($numrow == 0)
            echo"<font class=\"pn-normal2\">You have no messages&nbsp;&nbsp;&nbsp;";

             else
                echo "</b><a href=\"modules.php?op=modload&amp;name=Messages&amp;file=index\"><font class=\"pn-normal2\">&nbsp;You have&nbsp;".pnVarPrepForDisplay($numrow)." ";
                if ($numrow==1)  
                   echo "<font class=\"pn-normal2\">message</a>&nbsp;&nbsp;&nbsp;";    
                     elseif ($numrow>1)
                       echo "<font class=\"pn-normal2\">messages</a>&nbsp;&nbsp;&nbsp;";

                } else {
                     echo "<!-- Start Login Form -->\n"        
        ."<form action=\"user.php\" method=\"post\">\n"
        ."&nbsp;&nbsp;<font class=\"pn-normal2\">Username&nbsp;<input type=\"text\" name=\"uname\" size=10 maxlength=25>\n"
        ."&nbsp;<font class=\"pn-normal2\">Password <input type=\"password\" name=\"pass\" size=10 maxlength=\"20\">\n"
        ."<input type=\"checkbox\" value=\"1\" name=\"rememberme\" />&nbsp;<font class=\"pn-normal2\">Remember me\n"
        ."<input type=\"hidden\" name=\"module\" value=\"NS-User\" />\n"
        ."<input type=\"hidden\" name=\"op\" value=\"login\" />\n"
        ."<input type=\"hidden\" name=\"url\" value=\"".getenv("REQUEST_URI")."\" />\n"
        ."<input class=\"pn-button\" type=\"submit\" value=\"Login\" />\n" ;
        }
        ?>&nbsp;&nbsp;&nbsp;



    You will probably have to alter some of the display attributes and be careful where you add the tag for the login form - this can sometimes casue problems with layout - I normally put it outside of the table tags.

    Hope this helps,

    Kindest regards
    Lobos

    --
    -Lobos
    Professional PHP Framework Services: Concept, Development and Deployment
  • I haven't looked into the last visited bit, but this is how the messages code appears in Postnuke-V; either it shows a welcome to the user and how many messages and unread, or a login.

    Code

    <TD class="pn-normal" width="50%" align="left" valign="middle">
    <?php  ////// If logged in, display welcome, else display loginform on top bar //////
        if (pnUserLoggedIn()) { $username = pnUserGetVar('uname');
            echo "&nbsp;&nbsp;"._WELCOME.$username."!"; // If logged in, show greeting

        // Display private messages
        list($dbconn) = pnDBGetConn();
        $pntable = pnDBGetTables();
        $column = &$pntable['priv_msgs_column'];
        // Get total number of messages from database
            $result = $dbconn->Execute("SELECT count(*) FROM $pntable[priv_msgs] WHERE $column[to_userid]=" . pnUserGetVar('uid'));
            list($messages) = $result->fields;
        // Get number of unread messages
        $result2 = $dbconn->Execute("SELECT count(*) FROM $pntable[priv_msgs] WHERE $column[to_userid]=".pnUserGetVar('uid')." AND $column[read_msg]='0'");
        list($unread) = $result2->fields;
            if ($messages > 0) { ?>
            <SPAN class="topmenu"><?PHP echo _YOUHAVE ?> <A href="modules.php?op=modload&amp;name=Messages&amp;file=index"><B><?PHP echo pnVarPrepForDisplay($messages) 
           ."&nbsp;".($messages==1 ? _PRIVATEMSG : _PRIVATEMSGS) ?></B></A>, <?php echo "$unread "._UNREAD; ?>
            </SPAN>
    <?php   }
    } else { $username = pnConfigGetVar('anonymous'); // If not logged in, show login form ?>
        <!-- Login form on top bar -->
            <FORM class="login" action="user.php" method="post">
              &nbsp;&nbsp;<?PHP echo _NICKNAME ?>: <INPUT type="text" name="uname" size="12" maxlength="25">
              &nbsp;&nbsp;<?PHP echo _PASSWORD ?>: <INPUT type="password" name="pass" size="12" maxlength="25">
    <?php     if (pnConfigGetVar('seclevel') != 'High') { // only show checkbox if not high security level ?>
              &nbsp;&nbsp;<?PHP echo _REMEMBERME ?>: <INPUT type="checkbox" name="rememberme">&nbsp;
    <?php     } ?>
              <INPUT type="hidden" name="url" value="<?PHP echo getenv("REQUEST_URI") ?>">
              <INPUT type="hidden" name="module" value="NS-User">
              <INPUT type="hidden" name="op" value="login">
              <INPUT type="submit" value="<?PHP echo _LOGIN ?>">
            </FORM>
    <?php   } // end login form ?>
              </TD>

    I also have this in the lang/eng/global.php file:

    Code

    define('_WELCOME','Welcome ');
    if (!defined("_YOUHAVE")) {
    define('_YOUHAVE','You have'); }
    if (!defined("_PRIVATEMSG")) {
    define('_PRIVATEMSG','message'); }
    if (!defined("_PRIVATEMSGS")) {
    define('_PRIVATEMSGS','messages'); }
    define('_UNREAD','unread');


    Martin :D

This list is based on users active over the last 60 minutes.