Jump to content

problem with getTotal()


Frank Vèssia
 Share

Recommended Posts

Happy new year to everybody!

I have a problem counting pages.

I have a page with a list of paginated "messages" (pages). This works pretty good.

In top of the website there is always the navbar with other staff, one of those is the "Messages" link with a small count on the side for the not read emails.

I count the total messages using this code inside an external file, not in the page template.


function getIncomingmessages(){
 if (wire('user')->id){
   $userid = wire('user')->id;
   $member = wire('pages')->get("userid=$userid");
   if ($member->id){
     return $member->find("template=message,messagetype='inbox',read='',limit=2")->getTotal();
   }
 }
}

This works pretty good until I go to the next page on my messages page, the pageNum affects also this function in some way, so the total messages return null.

I thought the getTotal() always return the total.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...