The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Notify a user with notifications or alert

View previous topic View next topic Go down

Solved Notify a user with notifications or alert

Post by Luffy on November 22nd 2016, 3:18 pm

Technical Details


Forum version : #phpBB3
Position : Administrator
Concerned browser(s) : Mozilla Firefox, Google Chrome
Who the problem concerns : All members
Forum link : http://www.forum-promotion.com/

Description of problem


Hello,

So i create a donation system that a member can use it, tag a member and request a donation of points from his/her profile to the member (s)he tagged. What i want is that member who gets tagged to get notified wither to the notification list of fa_toolbar or to his/her browser that the member who posted has donated to him/her the X amount of points.

I do not wish to share the donation system code but if you know how i can add a script or something in my code in order to do this i would appreciate the help.

Thanks
avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by SLGray on November 22nd 2016, 9:22 pm

Do you mean the tag system?

@SLGray

If yes, you will get a notification if you have it set in your profile.


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 39135
Reputation : 2626
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on November 22nd 2016, 9:59 pm

Despite the tag mention, there are people that don't pay attention to the notifications. Maybe if an alert of the browser is sent to them it may be something better. But still with the notifications i want a notification that will contain information about the donation and not a single tag.





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on November 24th 2016, 2:10 pm

Bump!





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on November 25th 2016, 9:58 pm

@Luffy wrote:Bump!





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on November 28th 2016, 7:25 pm

Bump!





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on December 1st 2016, 3:59 pm

Bump.





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Kyo Panda on December 3rd 2016, 1:35 am

Hello,

Rely on the FA.Notification for any function you wish to create is a painful path trust me, I've been there. I would suggest that you intercept the "donation action" and, before it happens, you send a PM via Ajax with the notice.

Code:
; (function ($) {
    'use strict';

    $(function () {
        /** Before doing donation stuff */
        $.post('/privmsg', {
            username: 'Donation Receiver',
            subject: 'I\'ve just sent you a donation!',
            message: 'Lorem ipsum dolor sit amet.',
            mode: 'post',
            post: 1
        }).then(function () {
            /** Do the donation stuff */
            console.log('I\'m doing stuff.')
        });
    });
})(jQuery);

PMs have a natural alert, so that should be covered up.
avatar
Kyo Panda
Forumember

Male Posts : 33
Reputation : 19
Language : Portuguese, English
Location : Brazil

http://pt.rpgmaker.io

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on December 3rd 2016, 9:59 am

Hello @Kyo Panda and thank you for your reply.
That code pretty much does what i want but is there a possibility that we can add an alert on the browser too? Within that code, the member who receives the coins to receive an alert also?





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Kyo Panda on December 3rd 2016, 11:51 pm

The member who receive the coins (and the message) will receive the "You got a new message!" alert, default on Forumotion, assuming that the username field on the ajax call is properly filled with the receiver username.

Of course, we can go rad on this topic and on overall_header:

Code:
<!-- BEGIN switch_enable_pm_popup -->
    pm = window.open('{U_PRIVATEMSGS_POPUP}', '_faprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
    if(pm != null) { pm.focus(); }
<!-- END switch_enable_pm_popup -->

Inside the switch, we can make another interception to do "custom stuff":

Code:
<!-- BEGIN switch_enable_pm_popup -->
    $.get('/privmsg?folder=inbox', function (data) {
        if ($('a.topictitle:eq(0)', data).text().trim() === 'I\'ve just sent you a donation!') {
            console.log('Do awesome stuff!');
            return;
        }

        /** Default PM codez */
        pm = window.open('{U_PRIVATEMSGS_POPUP}', '_faprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
        if(pm != null) { pm.focus(); }
    });
<!-- END switch_enable_pm_popup -->

^ Like zis. Bouncy
avatar
Kyo Panda
Forumember

Male Posts : 33
Reputation : 19
Language : Portuguese, English
Location : Brazil

http://pt.rpgmaker.io

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on December 4th 2016, 1:44 pm

Hello @Kyo Panda,

Just to make sure i understood this correctly, with the second code to do custom stuff this reads the title of the PM and if it's the one entered 'I\'ve just sent you a donation!' it will show the alert on the console? If this is it then it's perfect.





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Kyo Panda on December 4th 2016, 2:03 pm

Yep, exactly.

---

Basically:

Code:
/** When a new PM is received and the alert option is ON on the Administrative Panel (default) */
<!-- BEGIN switch_enable_pm_popup -->
    /** Load the receiver PM page */
    $.get('/privmsg?folder=inbox', function (data) {
        /** If the last PM received has the title "I've just sent you a donation!" */
        if ($('a.topictitle:eq(0)', data).text().trim() === 'I\'ve just sent you a donation!') {
            /** Do custom stuff */
            console.log('Do awesome stuff!');
            /** And return without executing the default PM code below */
            return;
        }
 
        /** Default PM codez */
        pm = window.open('{U_PRIVATEMSGS_POPUP}', '_faprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
        if(pm != null) { pm.focus(); }
    });
<!-- END switch_enable_pm_popup -->

Bouncy
avatar
Kyo Panda
Forumember

Male Posts : 33
Reputation : 19
Language : Portuguese, English
Location : Brazil

http://pt.rpgmaker.io

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on December 4th 2016, 2:06 pm

An do i have to add the <script> tags or not? Because it's in the templates?





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Kyo Panda on December 4th 2016, 2:13 pm

This particular part on overall_header is already within a script tag, so you should be covered up.

Code:
   <script type="text/javascript">
   //<![CDATA[
   $(document).ready(function(){
      <!-- BEGIN switch_enable_pm_popup -->
         pm = window.open('{U_PRIVATEMSGS_POPUP}', '_faprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
         if(pm != null) { pm.focus(); }
      <!-- END switch_enable_pm_popup -->
      <!-- BEGIN switch_report_popup -->
         report = window.open('{switch_report_popup.U_REPORT_POPUP}', '_phpbbreport', 'HEIGHT={switch_report_popup.S_HEIGHT},resizable=yes,scrollbars=no,WIDTH={switch_report_popup.S_WIDTH}');
         if(report != null) { report.focus(); }
      <!-- END switch_report_popup -->
      <!-- BEGIN switch_ticker -->
         $(document).ready(function() {
            Ticker.start({
               height : {switch_ticker.HEIGHT},
               spacing : {switch_ticker.SPACING},
               speed : {switch_ticker.SPEED},
               direction : '{switch_ticker.DIRECTION}',
               pause : {switch_ticker.STOP_TIME}
            });
         });
      <!-- END switch_ticker -->
   });

   <!-- BEGIN switch_login_popup -->
      var logInPopUpLeft, logInPopUpTop, logInPopUpWidth = {LOGIN_POPUP_WIDTH}, logInPopUpHeight = {LOGIN_POPUP_HEIGHT}, logInBackgroundResize = true, logInBackgroundClass = false;
   <!-- END switch_login_popup -->

   <!-- BEGIN switch_login_popup -->
   $(document).ready( function() {
      $(window).resize(function() {
         var windowWidth = document.documentElement.clientWidth;
         var popupWidth = $("#login_popup").width();
         var mypopup = $("#login_popup");

         $("#login_popup").css({
         "left": windowWidth/2 - popupWidth/2
            });
      });
   });
   <!-- END switch_login_popup -->
   //]]>
   </script>
avatar
Kyo Panda
Forumember

Male Posts : 33
Reputation : 19
Language : Portuguese, English
Location : Brazil

http://pt.rpgmaker.io

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on December 4th 2016, 2:18 pm

So it should be like this:

or entered within the
Code:
//<![CDATA[


My bad, i didn't see the code very well. I did enter the code in the overall header but there is nothing showing up once i send a donation. I do get the pm and the notifications on the fa_toolbar but no browser alert.





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Kyo Panda on December 4th 2016, 2:35 pm

Can you post your overall_header here, so we can check what is happening? Smile

---

EDIT.: No problems. ^-^


Last edited by Kyo Panda on December 4th 2016, 2:40 pm; edited 1 time in total
avatar
Kyo Panda
Forumember

Male Posts : 33
Reputation : 19
Language : Portuguese, English
Location : Brazil

http://pt.rpgmaker.io

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on December 4th 2016, 2:38 pm

Oh well, i changed the console.log to alert and it worked. All i wanted is an alert to show up!!

Thanks so much @Kyo Panda!!





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by brandon_g on December 4th 2016, 2:56 pm

May this be archived now @Luffy ?

-Brandon


Remember to mark your topic when a solution is found.
avatar
brandon_g
Support Moderator
Support Moderator

Male Posts : 5791
Reputation : 538
Language : English
Location : USA

http://broadcastingduo.forumotion.com/

Back to top Go down

Solved Re: Notify a user with notifications or alert

Post by Luffy on December 4th 2016, 3:08 pm

Oops! Embarassed I completely forgot i could do that! Razz
Thanks once again Kyo Panda!!

Problem solved & topic archived.
Please read our forum rules: ESF General Rules





avatar
Luffy
Manager
Manager

Male Posts : 4624
Reputation : 466
Language : Greek, English
Location : Greece

http://helpgr.forumgreek.com/forum

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum