TinyPortal

Development => Block Codes => Topic started by: shengton on September 22, 2008, 05:50:20 PM

Title: [SOLVED] Need a Private Message or PM Block
Post by: shengton on September 22, 2008, 05:50:20 PM
Where can I find a PM Block?

Thanks and God bless. :)
Title: Re: Need a Private Message or PM Block
Post by: Ken. on September 22, 2008, 05:55:49 PM
Hi shengton, welcome to TinyPortal.

If you give a more detailed description of what you need then maybe one of our coders will be able to assist you.
Title: Re: Need a Private Message or PM Block
Post by: shengton on September 22, 2008, 06:03:41 PM
Thanks for the quick reply sir.

I have a forum site and if someone will PM me I can't immediately notice it. I want a phpscript that I can immediately notice when someone will PM or Private Message.
Title: Re: Need a Private Message or PM Block
Post by: Ken. on September 22, 2008, 06:17:32 PM
You should be able to set your forum to "Show a popup when you receive new messages?"

Profile>Personal Message Options>Show a popup when you receive new messages?
Title: Re: Need a Private Message or PM Block
Post by: shengton on September 22, 2008, 06:22:50 PM
Thanks for that sir but I want all my members automatically applied using a phpscript. Here's a code but it nothings happen.

if($context['user']['is_logged'] && $context['user']['unread_messages']>0)
  echo '<a href="',$scripturl,'?action=pm"><img src="',$settings['images_url'],'/menu/newpm.gif"/></a>';
Title: Re: Need a Private Message or PM Block
Post by: Ken. on September 22, 2008, 06:27:40 PM
PM's are actually a function of SMF, not TinyPortal.
Someone here may be able to give you an answer, but chances are you'll get help lots faster on the SMF forum.
Title: Re: Need a Private Message or PM Block
Post by: shengton on September 22, 2008, 06:29:38 PM
Ahh ok thanks for your help sir.. :)
Title: Re: Need a Private Message or PM Block
Post by: Ken. on September 22, 2008, 06:31:57 PM
Found it for you...
http://www.simplemachines.org/community/index.php?topic=185521.msg1180646#msg1180646

Search is your friend. ;)
Title: Re: Need a Private Message or PM Block
Post by: Ianedres on September 22, 2008, 08:28:38 PM
Create a php block and use the global to set the scope for the $context and $settings variables; the rest is your code:

global $context, $settings;

if($context['user']['is_logged'] && $context['user']['unread_messages']>0)
  echo '<a href="',$scripturl,'?action=pm"><img src="',$settings['images_url'],'/menu/newpm.gif"/>[/url]';


Once you enable the block to display, it will notify the member on new messages...




Title: Re: Need a Private Message or PM Block
Post by: shengton on September 27, 2008, 06:46:04 AM
Thanks lanedres....Greate :)
Title: Re: Need a Private Message or PM Block
Post by: Ianedres on September 27, 2008, 10:19:09 AM
Glad to help...  will mark as solved.
Title: Re: [SOLVED] Need a Private Message or PM Block
Post by: G6Cad on September 27, 2008, 10:56:03 AM
I will move this to block code and snippets from the request board
Title: Re: [SOLVED] Need a Private Message or PM Block
Post by: Ianedres on September 27, 2008, 12:27:06 PM
This is untested, but you can try this to show just how many messages a member has in the mouseover tip over the image...

global $context, $settings, $scripturl;

$msgcount = $context['user']['unread_messages'];

if($context['user']['is_logged'] && $msgcount > 0)
{
echo '<a href="',$scripturl,'?action=pm">';
echo '<img src="',$settings['images_url'],'/menu/newpm.gif" title="You have '.$msgcount.' message' . ($message = $msgcount > 1 ? 's' : ''). ' awaiting." /></a>';
}


Basically, assigns the variable $msgcount (just to use a short name) and in the echo line where the title tag is, it should output an 's' if more than one message awaits. Broke it up into two lines just to make it read better...