PDA

View Full Version : Notifications in Navbar


GamerPerfection
04-01-2013, 12:48 PM
Is there any way I can get the normal vB notifications (like new PM's etc) to appear in the Navbar instead of the header?

Brandon Sheley
04-01-2013, 01:18 PM
You'll need to edit the template, did you purchase or download your style somewhere?
I'd ask there.

GamerPerfection
04-01-2013, 02:02 PM
I made the template myself.

kh99
04-01-2013, 03:19 PM
When you're rendering your template, register the notification variables to your template, like:
$templater->register('notifications_menubits', $notifications_menubits);
$templater->register('notifications_total', $notifications_total);



Then look at the original navbar template and copy the parts that display notifications_menubits and notifications_total (unless that's the part you were asking about, in which case this doesn't help :) ).

GamerPerfection
04-01-2013, 03:37 PM
That's where I get lost, I don't know anything about rendering. I tried reading this: https://vborg.vbsupport.ru/showthread.php?t=228078 but it loses me very quickly.

kh99
04-01-2013, 03:54 PM
OK, when you say you made the template yourself, do you mean that you made a new one called navbar to replace the original? In that case you don't have to worry about the registering, you just need to find the code from the original that mention notifications_menubits and notifications_total, and copy it to your new template.

GamerPerfection
04-01-2013, 04:11 PM
Oh sorry, my bad, bad wording. I meant I made the style myself. It is still using the original Navbar template.

kh99
04-01-2013, 04:41 PM
Actually, it's my fault - I see now the original question is how you would move it to the navbar from the header. I kind of came in in the middle and got confused.

Anyway, it's the same advice - find the code in the header that displays notifications_total and notifications_menubits, and copy it to your navbar template. As it turns out, those are already registered to the navbar template, so you don't have to worry about that (probably it's left over from vb3 or something). Here's the code from the header template:

<vb:if condition="$notifications_total">
<li class="popupmenu notifications" id="notifications">
<a class="popupctrl" href="usercp.php{vb:raw session.sessionurl_q}">{vb:rawphrase your_notifications}: <span class="notifications-number"><strong>{vb:raw notifications_total}</strong></span></a>
<ul class="popupbody popuphover">
{vb:raw notifications_menubits}
</ul>
</li>
<vb:else />
<li class="popupmenu nonotifications" id="nonotifications">
<a class="popupctrl" href="usercp.php{vb:raw session.sessionurl_q}">{vb:rawphrase your_notifications}</a>
<ul class="popupbody popuphover">
<li>{vb:rawphrase no_new_messages}</li>
<vb:if condition="$show['pmmainlink']"><li><a href="private.php{vb:raw session.sessionurl_q}">{vb:rawphrase inbox}</a></li></vb:if>
</ul>
</li>
</vb:if>


but that uses <li> tags because it's inside <ul> tags, so if you don't have the same situation in your navbar template then you'll have to do something about that.

GamerPerfection
04-01-2013, 04:48 PM
When you say copy it to my navbit template, which template is that? I don't have a navbit, do you mean navbar?

Almost got it working. Just need to figure out how to change the font size and colour as it's using what was in the header.

--------------- Added 1364840459 at 1364840459 ---------------

I believe I have it working now.

http://www.gamerperfection.com/images/notifications.png

The only thing is the font is slightly different from the navbar items. And when there are no notifications the font size is smaller.

kh99
04-01-2013, 06:59 PM
navbit was a typo, I meant navbar. If you look at the CSS classes being used in the tags, you could probably figure out the font issue.