![]() |
How to display pm notifications in a custom template?
Hi,
I've registered a custom template to include inside the header template with Code:
{vb:raw mytemplate} Code:
<vb:if condition="$show['member']"> Code:
<vb:if condition="$notifications_total"> So if I put this code in mytemplate - Code:
<vb:if condition="$notifications_total"><div>there are notifications</div> The exact same code in the header template works as expected. Does anyone know a solution for this? |
You will need to register the variable $notifications_total for use in your custom template.
Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide |
Hi Lynne! Thanks for the swift response.
I've just been reading through that thread, and I'm really glad to find you're still posting here. I found this example code there: Code:
$templater = vB_Template::create('memberbar_member_basic'); So I took my existing plugin... Code:
$templater = vB_Template::create('ubermenu'); Code:
$templater = vB_Template::create('ubermenu'); Code:
vB_Template::preRegister('ubermenu', array('notifications_total' => $notifications_total)); Help? |
First, you may combine the 3 lines:
PHP Code:
PHP Code:
PHP Code:
|
Thank you.
I'm sure you're right. **EDIT** Er, let me just delete everything I wrote before I found the stray ' in the code :o . I still haven't got it working, but I'll post a better update after I've tested a few more things. --------------- Added [DATE]1461490554[/DATE] at [TIME]1461490554[/TIME] --------------- Sorry to say that this - Code:
$templater = vB_Template::create('ubermenu'); I replaced my whole ubermenu template with the original notifications code, and finally with Code:
<div><vb:if condition="$notifications_total">There are notifications<vb:else />Yes, we have no notifications</vb:if> |
What hook location are you using for your plugin?
|
parse_templates
(I tried 'global_start' first, but the template didn't appear at all.) |
Try "global_setup_complete"...:)
|
Nope - template disappears altogether again.
|
Okay, here's my workaround:
The "mytemplate" template: HTML Code:
<div> PHP Code:
|
All times are GMT. The time now is 07:22 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|