Skip to main content
Topic: If ( there is an alert) (Read 7014 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: If ( there is an alert)

Reply #15

This ?

Code: [Select]
/* Popup alert notification using Growl Notifications */
function growl_notification()
{
global $context;
if (!empty($context['user']['mentions']))
// Say they have unread alerts.
echo '
<body ng-app="af_notify" ng-controller="growlCtrl">
  
    <growl-notifications></growl-notifications>

    <growl-notification>
      Psst ! You have unread notifications
    </growl-notification>

  </body>';
}

Re: If ( there is an alert)

Reply #16

Works fine if I use only echo part. ie, remove if ( context ) in above code


Re: If ( there is an alert)

Reply #17

$context['user']['mentions'] > 0


Re: If ( there is an alert)

Reply #19

Yes. This is mention alerts. It cannot be configured. It will show you an alert window and take your attention to new like or @ mention or whatever it is. Besides, I am using AngularJS

PS : The display is not yet available

Code: [Select]
/* Popup alert notification using Growl Notifications */
function growl_based_notification()
{
global $context;
   
   if (!empty($context['user']['mentions']) > 0)
// Say they have unread alerts.
echo '
  
<body ng-app="af_notify" ng-controller="growlCtrl">
   
 
 
    <growl-notifications>

    <growl-notification>
      Psst ! You have unread notifications
    </growl-notification>

</growl-notifications>
   

  </body>';
}

Re: If ( there is an alert)

Reply #20

1st: <body> is a tag with a specific meaning, you should not use it in the middle of a page "at random".
2nd: empty returns true or false, there is no reason to do a !empty($something) > 0

Try with:
Code: [Select]
	global $user_info;
if (!empty($user_info['mentions']))
Bugs creator.
Features destroyer.
Template killer.

Re: If ( there is an alert)

Reply #21

Sorry, I didn't see the !empty check :)

Re: If ( there is an alert)

Reply #22

Using this, but no Alerts display

Code: [Select]
/* Popup alert notification using Growl Notifications */

function growl_based_notification()
{
global $user_info;
   
if (!empty($user_info['mentions']))
   
// Say they have unread alerts.
      
        echo "<pre>" . print_r($user_info, 1) . "<pre>\n";
echo '
   
 
<html ng-app="af_notify" ng-controller="growlCtrl">
  
 
 
    <growl-notifications>

    <growl-notification>
      Psst ! &nbsp; You have unread notifications
    </growl-notification>

</growl-notifications>
  

  </html>';
}

growl_based_notification();

But when I add

Code: [Select]
 echo "<pre>" . print_r($user_info, 1) . "<pre>\n";

it shows the alert window. But does not vanish even if I logout



Re: If ( there is an alert)

Reply #23

I have added a dismiss button

But still no luck with the condition :(



Re: If ( there is an alert)

Reply #24

Where are you calling that function from?
Bugs creator.
Features destroyer.
Template killer.

Re: If ( there is an alert)

Reply #25

I am simply copy pasting this whole code on index.template.php

Re: If ( there is an alert)

Reply #26

You are declaring a function.
If you declare a function you have to call it in order to let it run.
So, where are you calling this function in index.template.php?
Bugs creator.
Features destroyer.
Template killer.

Re: If ( there is an alert)

Reply #27

Yes, just after declaring it.

Re: If ( there is an alert)

Reply #28

@emanuele , anything you can do ?

Re: If ( there is an alert)

Reply #29

Then you are running it at the wrong time.
You have to call that function in a particular point of the template, not when the file is "included".
Most likely you have to call that function at the beginning of template_body_above or somewhere like that, but by all means inside a template_* function or through the template layers mechanism.
Bugs creator.
Features destroyer.
Template killer.