1
Ft24v2
Need Some Help
  • 2008/1/6 22:38

  • Ft24v2

  • Just popping in

  • Posts: 86

  • Since: 2007/1/30


So ive made a tool bar for my website, and the tool bar allows me to add in custom html gadgets. What i want to do is add in a feature that lets a user know when they have a new pm message. How would i go about doing this? Where would i start ?

2
Bleekk
Re: Need Some Help
  • 2008/1/6 23:45

  • Bleekk

  • Theme Designer

  • Posts: 941

  • Since: 2002/12/14


look here how it's done in user block

<table cellspacing="0">
  <
tr>
    <
td id="usermenu">
      <{if 
$xoops_isadmin}>
        <
class="menuTop" href="<{$xoops_url}>/admin.php"><{$block.lang_adminmenu}>a>
        <
a href="<{$xoops_url}>/user.php"><{$block.lang_youraccount}>a>
      <{else}>
        <
class="menuTop" href="<{$xoops_url}>/user.php"><{$block.lang_youraccount}>a>
      <{/if}>
      <
a href="<{$xoops_url}>/edituser.php"><{$block.lang_editaccount}>a>
      <
a href="<{$xoops_url}>/notifications.php"><{$block.lang_notifications}>a>
      <{if 
$block.new_messages 0}>
        <
class="highlight" href="<{$xoops_url}>/viewpmsg.php"><{$block.lang_inbox}> (<span style="color:#ff0000; font-weight: bold;"><{$block.new_messages}>span>)a>
      <{else}>
        <
a href="<{$xoops_url}>/viewpmsg.php"><{$block.lang_inbox}>a>
      <{/if}>
      <
a href="<{$xoops_url}>/user.php?op=logout"><{$block.lang_logout}>a>
    td>
  tr>
table>


I'm sure you can use the second if statement

3
stefan88
Re: Need Some Help
  • 2008/1/7 6:31

  • stefan88

  • Community Support Member

  • Posts: 1086

  • Since: 2004/9/20


Hi,

you will have to put something like this in your theme file:

Quote:
<{if $xoops_isuser}>

<{php}>
GLOBAL $xoopsUser;
$pm_handler =& xoops_gethandler('privmessage');
$uid = $xoopsUser->getVar('uid');
$criteria = new CriteriaCompo(new Criteria('read_msg', 0));
$criteria->add(new Criteria('to_userid', $uid));
$msgcount = $pm_handler->getCount($criteria);
$GLOBALS['xoopsTpl']->assign('msgcount', $msgcount);
<{/php}>

<{if $msgcount > 0}>
You have <{$msgcount} new message border="0" />
<{else}>
 You have no new messages
<{/if}>

<{/if}>


this uses diferent image to display if there are new messages or not with alt text "You have X new messages" or "You have no new messages"

You may put php part in a smarty plugin and keep logik and presentation separated.
..

4
snow77
Re: Need Some Help
  • 2008/1/7 7:11

  • snow77

  • Just can't stay away

  • Posts: 864

  • Since: 2003/7/23


or it can be this instead

<{xoInboxCount assign=pmcount}>
            <
a href="<{xoAppUrl /viewpmsg.php}>">
            <{if 
$pmcount}>
                <
img src="<{xoImgUrl images/inbox-full.png}>" alt="Inbox (<{$pmcount}>)" title="You have <{$pmcount}> unread messages" /> Inbox (<{$pmcount}>)
            <{else}>
                <
img src="<{xoImgUrl images/inbox.png}>" alt="Inbox" title="Show your inbox content" /> Inbox 
            
<{/if}>
            a>

5
Ft24v2
Re: Need Some Help
  • 2008/1/7 7:33

  • Ft24v2

  • Just popping in

  • Posts: 86

  • Since: 2007/1/30


Okay so this code:

<{if $xoops_isuser}>

<{
php}>
GLOBAL 
$xoopsUser;
$pm_handler =& xoops_gethandler('privmessage');
$uid $xoopsUser->getVar('uid');
$criteria = new CriteriaCompo(new Criteria('read_msg'0));
$criteria->add(new Criteria('to_userid'$uid));
$msgcount $pm_handler->getCount($criteria);
$GLOBALS['xoopsTpl']->assign('msgcount'$msgcount);
<{/
php}>

<{if 
$msgcount 0}>
<
a href="<{$xoops_url}>/viewpmsg.php"><img src="<{$xoops_imageurl}>images/prvmsg_on.jpg" alt=You&nbsp;have&nbsp;<{$msgcount}>&nbsp;new&nbsp;message border="0" />a>
<{else}>
&
nbsp;<a href="<{$xoops_url}>/viewpmsg.php"><img src="<{$xoops_imageurl}>images/prvmsg_off.jpg" alt="You have no new messages" border="0" />a>
<{/if}>

<{/if}>


or this code:

<{xoInboxCount assign=pmcount}>
            <
a href="<{xoAppUrl /viewpmsg.php}>">
            <{if 
$pmcount}>
                <
img src="<{xoImgUrl images/inbox-full.png}>" alt="Inbox (<{$pmcount}>)" title="You have <{$pmcount}> unread messages" /> Inbox (<{$pmcount}>)
            <{else}>
                <
img src="<{xoImgUrl images/inbox.png}>" alt="Inbox" title="Show your inbox content" /> Inbox 
            
<{/if}>
            a>


Goes into my sites them file, or does it go into the theme of the gadget im making for the toolbar ?

6
stefan88
Re: Need Some Help
  • 2008/1/7 17:43

  • stefan88

  • Community Support Member

  • Posts: 1086

  • Since: 2004/9/20


Quote:
Goes into my sites them file, or does it go into the theme of the gadget im making for the toolbar


The code I posted (and the code from snow77) should go in theme.html file in theme/YOUR_SITE_THEME folder.

I do not understand what you mean by "theme of the gadget im making" ... Is it "template for the module I'm making" (there is diference between theme and template)?
..

7
mboyden
Re: Need Some Help
  • 2008/1/7 21:27

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


The second set of code posted by snow77 should work. The new xoInboxCount is a new Smarty subroutine that will get the count of PMs for you. If you use that code in anything after 2.0.15 then it should work just fine for you. Earlier versions will require PHP code.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

Login

Who's Online

146 user(s) are online (47 user(s) are browsing Support Forums)


Members: 0


Guests: 146


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits