0
Welcome Guest! Login
0 items Join Now

Add New Message count to module

    • Skates's Avatar
    • Skates
    • Newbie
    • Posts: 15
    • Thanks: 0

    Add New Message count to module

    Posted 17 years 5 months ago
    • I am using Dimensions, Fireboard, Community Builder, and Uddeim on my site. I'm still really new to this so am just figuring things out. Everything is integrated but I wanted a module that would show Private messages. I found the links and created one that displays in the forums. What I want to do is have a little (0),(1) or whatever the count of new messages in the in box is display next to "Inbox" in my Private Messaging module.


      http://www.joomlatest.nfb-clan.com/index.php/Forums/
  • Re: Add New Message count to module

    Posted 17 years 5 months ago
    • What private messaging component are you using? ok I see UdeIM ( ::) dumb me) Well you have to do some serious counting with an MySQL query, select count number of messages present for that user,select count how many are read, and with these two values you could echo some results in the way you want!

      You might get more rapid help with this on the UddeIM forums
    • No money to extend membership :(
    • Skates's Avatar
    • Skates
    • Newbie
    • Posts: 15
    • Thanks: 0

    Re: Add New Message count to module

    Posted 17 years 5 months ago
    • Okay, I see there is a field in the uddeim database named "toread" which is a 1 if unread and 0 if read. So I would need to have something that would total up the "toread" based off the user and then display that total?
  • Re: Add New Message count to module

    Posted 17 years 5 months ago
    • thats exactly it! As an example, say you have a table called _INBOX

      1. TABLENAME: _INBOX

      : towho : fromwho : subject : date : read_status :
      : user1 : user2 : hello : 27/07/00 : 1 :
      : user1 : user3 : hello you : 27/07/00 : 0 :

      2. Select and count the number of messages in _INBOX table, for which towho is the user in question
      global $my->username  // this is joomla style of doing things 
       
      SELECT COUNT(*) as "my messages"
      FROM _INBOX
      WHERE `towho` = $my->username;
       

      This should give you the number of messages stored in that table for that use!

      This is just raw SQL but surely u will use joomla style of accessing the database, which makes life a lot easier.

      Then Count those unread in the same where using the AND cause youll be having two conditions so your WHERE will be
       
      WHERE `towho` = $my->username AND `read_status` = 0;  // be careful with intergers 8)
       

      Another rather simple approach which i will rather use is to Load an ObjectList (Joomla Noise ;D well an array) of results with messages addresssed to that user so doing it joomla style
      global $my->username  // this is joomla style of doing things
      global $database; 
       
      $query = "SELECT *".
                    "\n FROM _INBOX".
                    "\n WHERE `towho` = $my->username ";
       
      $database->setQuery($query);
       
      //normally check to see if your SQL is being worked properly at this point, but ill skip this and Load an array of results
       
      $results = $database->LoadObjectList() ;
       
      //you can then use php to count this results
       
      $total = count($results);
       
      //you then count the number of results in the array for which $results->read_status
       
      $unread = count($results->read_status == '0');
       
      //echo everything your style
       
      echo 'You have '.$total.' messages of which '.$unread.' are unread'; //infact you could do this whatever way you wish!
       
    • Last Edit: 17 years 5 months ago by .
    • No money to extend membership :(
    • Skates's Avatar
    • Skates
    • Newbie
    • Posts: 15
    • Thanks: 0

    Re: Add New Message count to module

    Posted 17 years 5 months ago
    • Thanks, I'll play around with that later when things slow down at work and see if I can get it working.
    • Skates's Avatar
    • Skates
    • Newbie
    • Posts: 15
    • Thanks: 0

    Re: Add New Message count to module

    Posted 17 years 5 months ago
    • When I use what you gave me in that third example I get:
      Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /home/nfbclanc/public_html/Joomlatest/modules/mod_cblogin.php on line 2

      And on line 2 is:
      global $my->username

      If I change it to:
      global $my_username

      The error goes away but I don't get any results out of my query. Sorry but I'm really new at this.

      My tablename is _uddeim

      : fromid : toid : subject : date : toread :
      : 63 : 64 : hello : 27/07/00 : 1 :
      : 64 : 63 : hello you : 27/07/00 : 0 :
  • Re: Add New Message count to module

    Posted 17 years 5 months ago
    • no dont just copy it into your script, its just an example! ok ill try to be abit more explicit

      $my is a global joomla object ::)! and you could use it to access sevrall user variables like

      $my->id , will give you user id
      $my->username, will give you the user name, so that is a standard stuff!

      so echo $my->username should give you the user name!

      ok

      Your error suggest that you have not closed you php statements with a semicolon ;

      can i have a look at your code?
    • Last Edit: 17 years 5 months ago by .
    • No money to extend membership :(
    • Skates's Avatar
    • Skates
    • Newbie
    • Posts: 15
    • Thanks: 0

    Re: Add New Message count to module

    Posted 17 years 5 months ago
    • If it is completely screwed up please be gentle. :P
      <?php
      global $my->id;
      global $database; 
       
      $query = "SELECT *".
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "\n FROM _UDDEIM".
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "\n WHERE `toid` = $my->id ";
       
      $database->setQuery($query);
       
      $results = $database->LoadObjectList() ;
       
      $total = count($results);
       
      $unread = count($results->read_status == '0');
       
      echo 'Messages - Total '.$total.' / New '.$unread.';
       
      ?>
  • Re: Add New Message count to module

    Posted 17 years 5 months ago
    • nice try but there were a few errors in your script ok ill explain this again. this time i will take a look at the uddeIM table for you!
      <?php
       
      global $database, $my->id ;
       
      $query = "SELECT *&nbsp; ".
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "\n FROM&nbsp; `#__uddeim`".
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "\n WHERE&nbsp; `toid` = $my->id" ;
       
      $database->setQuery($query) ;
       
      //check for any errors
                
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( !($database->loadObjectList()) ) {
                     echo $database->stderr();
                     return false;
                 }
       
      //object lists
       
      $messages = $database->loadObjectList();
       
      //count number of $messages
       
      $total = count($database->loadObjectList()); usint the php count function
       
      //count unread messages i.e number or arrays in object lists for wich $messages->toread is equivalent to zero
       
      $unread = count($messages->toread == '0') ; //not so sure here will check this for you tommorrow if it does not work
       
       
      //out put the results
       
      echo 'You have'.$total.' messages, of which '.$unread.' are unread' ;
       
       
      ?>
    • No money to extend membership :(
    • Skates's Avatar
    • Skates
    • Newbie
    • Posts: 15
    • Thanks: 0

    Re: Add New Message count to module

    Posted 17 years 5 months ago
    • It still gives me that same error:
      Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /home/nfbclanc/public_html/Joomlatest/modules/mod_cblogin.php on line 3

      Does database in line 3 need to be changed to the name of mysql database?

Time to create page: 0.070 seconds