Im trying(failing for now) to color the private messages indicator like this:
== 0 will be normal color
!= 0 will be other color
cant find the right coding to implement this idea, help required from godlike coders
You can use jQuery for that.
This is what I made (I'm not a master on jQuery so... if you find another way or someone has a better way to achieve this, go ahead and use their code).
HTML
<span class="pms">{$mybb->user['pms_unread']}</span>
That's my custom class (pms) for the number of private messages.
jQuery (add this at the end of all the code from the headerinclude template)
<script type="text/javascript">
jQuery(function(){
if (jQuery(".pms").text() == "0") {
jQuery(".pms").css("color", "#ffffff");
} else {
jQuery(".pms").css("color", "#ff0000");
}
});
</script>
There I'm saying that if the PMS class text is equal to 0 then, the colour of the class is #FFFFFF (White), else the colour of the class is #FF0000 (Red).
Hope you can find this useful.
Regards.
(2016-04-25, 07:49 PM)eNvy Wrote: [ -> ]You can use jQuery for that.
This is what I made (I'm not a master on jQuery so... if you find another way or someone has a better way to achieve this, go ahead and use their code).
HTML
<span class="pms">{$mybb->user['pms_unread']}</span>
That's my custom class (pms) for the number of private messages.
jQuery (add this at the end of all the code from the headerinclude template)
<script type="text/javascript">
jQuery(function(){
if (jQuery(".pms").text() == "0") {
jQuery(".pms").css("color", "#ffffff");
} else {
jQuery(".pms").css("color", "#ff0000");
}
});
</script>
There I'm saying that if the PMS class text is equal to 0 then, the colour of the class is #FFFFFF (White), else the colour of the class is #FF0000 (Red).
Hope you can find this useful.
Regards.
Brilliant solution.
I can't thank u enough brother... firstly for the effort, and secondly for the lesson.
(2016-04-25, 10:06 PM)Protesqu Wrote: [ -> ] (2016-04-25, 07:49 PM)eNvy Wrote: [ -> ]You can use jQuery for that.
This is what I made (I'm not a master on jQuery so... if you find another way or someone has a better way to achieve this, go ahead and use their code).
HTML
<span class="pms">{$mybb->user['pms_unread']}</span>
That's my custom class (pms) for the number of private messages.
jQuery (add this at the end of all the code from the headerinclude template)
<script type="text/javascript">
jQuery(function(){
if (jQuery(".pms").text() == "0") {
jQuery(".pms").css("color", "#ffffff");
} else {
jQuery(".pms").css("color", "#ff0000");
}
});
</script>
There I'm saying that if the PMS class text is equal to 0 then, the colour of the class is #FFFFFF (White), else the colour of the class is #FF0000 (Red).
Hope you can find this useful.
Regards.
Brilliant solution.
I can't thank u enough brother... firstly for the effort, and secondly for the lesson.
Most of the time when you can do something with html or css (and you don't want to use a plugin), jQuery comes and save us haha.
(2016-04-25, 10:14 PM)eNvy Wrote: [ -> ] (2016-04-25, 10:06 PM)Protesqu Wrote: [ -> ] (2016-04-25, 07:49 PM)eNvy Wrote: [ -> ]You can use jQuery for that.
This is what I made (I'm not a master on jQuery so... if you find another way or someone has a better way to achieve this, go ahead and use their code).
HTML
<span class="pms">{$mybb->user['pms_unread']}</span>
That's my custom class (pms) for the number of private messages.
jQuery (add this at the end of all the code from the headerinclude template)
<script type="text/javascript">
jQuery(function(){
if (jQuery(".pms").text() == "0") {
jQuery(".pms").css("color", "#ffffff");
} else {
jQuery(".pms").css("color", "#ff0000");
}
});
</script>
There I'm saying that if the PMS class text is equal to 0 then, the colour of the class is #FFFFFF (White), else the colour of the class is #FF0000 (Red).
Hope you can find this useful.
Regards.
Brilliant solution.
I can't thank u enough brother... firstly for the effort, and secondly for the lesson.
Most of the time when you can do something with html or css (and you don't want to use a plugin), jQuery comes and save us haha.
Indeed.
I used jQuery a while ago for something else, but it was quite different from this.
Thank you again!