2014-05-24, 06:09 PM
Hi, I know for most of the users I think this will be pretty easy, but some people like me it's so hard to make things like this to happen
Preview:
Note that the circle behind the number is my own class, so make yours and make a beauty custom notification
Version 2.0:
You can also use this alternative script working with DOMContentLoaded, works way faster, I recommend this one. (Thanks @Leefish for the tip about using DOM for faster script loading)
1.- Add wherever you want the number to show up:
2.- Add below the code you added on step 1:
--------------------------------------------------------------------
Version 1.0:
1.- Add this code to top of header_welcomeblock_member (or any other place you want to show the number of alerts):
2.- Add wherever you want the number to show up:
3.- Add below the code you added on step 2:
---------------------------------------------------------------
Comments for v1 and v2:
The last code as you can see only will show up if the numbers of alerts is different that cero (!=0), you can always change it for anything you want
I hope this works fine for you, and wish to help anybody that had problems trying to do this
Preview:
Note that the circle behind the number is my own class, so make yours and make a beauty custom notification
Version 2.0:
You can also use this alternative script working with DOMContentLoaded, works way faster, I recommend this one. (Thanks @Leefish for the tip about using DOM for faster script loading)
1.- Add wherever you want the number to show up:
<span id="showalert"></span></div>
2.- Add below the code you added on step 1:
<script>
var showalert = document.getElementById("showalert");
function Alert(func)
{
window.addEventListener('DOMContentLoaded', func, false);
}
{
if ({$mybb->user['unreadAlerts']} != 0) {
showalert.className = notif.className + "Insert the class you want to give the element";
showalert.innerHTML = "{$mybb->user['unreadAlerts']}";}
}
</script>
--------------------------------------------------------------------
Version 1.0:
1.- Add this code to top of header_welcomeblock_member (or any other place you want to show the number of alerts):
<body onload=Alert()>
2.- Add wherever you want the number to show up:
<span id="showalert"></span></div>
3.- Add below the code you added on step 2:
<script>
var showalert = document.getElementById("showalert");
function Alert()
{
if ({$mybb->user['unreadAlerts']} != 0) {
showalert.className = notif.className + "Insert the class you want to give the element";
showalert.innerHTML = "{$mybb->user['unreadAlerts']}";}
}
</script>
---------------------------------------------------------------
Comments for v1 and v2:
The last code as you can see only will show up if the numbers of alerts is different that cero (!=0), you can always change it for anything you want
I hope this works fine for you, and wish to help anybody that had problems trying to do this