The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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> <vb:else /><div>no notifications here</div> </vb:if> The exact same code in the header template works as expected. Does anyone know a solution for this? |
#2
|
||||
|
||||
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 |
#3
|
|||
|
|||
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'); $memberbar_member_basic = $templater->render(); vB_Template::preRegister('navbar', array('notifications_menubits' => $notifications_menubits)); vB_Template::preRegister('navbar', array('memberbar_member_basic' => $memberbar_member_basic)); vB_Template::preRegister('navbar', array('notifications_menubits' => $notifications_menubits)); So I took my existing plugin... Code:
$templater = vB_Template::create('ubermenu'); $ubermenu = $templater->render(); vB_Template::preRegister('header', array('ubermenu' => $ubermenu)); Code:
$templater = vB_Template::create('ubermenu'); $ubermenu = $templater->render(); vB_Template::preRegister('header', array('notifications_menubits' => $notifications_menubits)); vB_Template::preRegister('header', array('notifications_total' => $notifications_total)); vB_Template::preRegister('header', array('ubermenu' => $ubermenu)); Code:
vB_Template::preRegister('ubermenu', array('notifications_total' => $notifications_total)); Help? |
#4
|
||||
|
||||
First, you may combine the 3 lines:
PHP Code:
PHP Code:
PHP Code:
|
#5
|
|||
|
|||
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 . 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'); $templater->register('notifications_menubits', $notifications_menubits); $templater->register('notifications_total', $notifications_total); $ubermenu = $templater->render(); vB_Template::preRegister('header', array('ubermenu' => $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> <ul>{vb:raw notifications_menubits}</ul></div> |
#6
|
||||
|
||||
What hook location are you using for your plugin?
|
#7
|
|||
|
|||
parse_templates
(I tried 'global_start' first, but the template didn't appear at all.) |
#8
|
||||
|
||||
Try "global_setup_complete"...
|
#9
|
|||
|
|||
Nope - template disappears altogether again.
|
#10
|
||||
|
||||
Okay, here's my workaround:
The "mytemplate" template: HTML Code:
<div> <vb:if condition="$notifications_total"> there are notifications <vb:else /> no notifications here </vb:if> </div> PHP Code:
|
Благодарность от: | ||
Lynne |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|