Log in

View Full Version : Fetch Template in Plugin


dfc005
02-10-2009, 01:07 AM
Is it possible to fetch a template in a plugin and then output the template?

I'm trying to do it and it doesn't seem to work for me.....

vbplusme
02-10-2009, 01:16 AM
eval('$YourTemplate = "' . fetch_template('YourTemplate') . '";');

Place $YourTemplate where you want it to display and it should dump the contents of that template.

How did you define the template? What hook to use?

dfc005
02-10-2009, 01:22 AM
OK, that does seem to almost work. I'm sure I'd tried it numerous times and it didn't work. I'm using the global_start hook as I'm trying to add the template copy to custom header. This is my template I'm fetching....


<if condition="$show['notifications']">
<b><a href="{$channel_fix}usercp.php$session[sessionurl_q]">$vbphrase[your_notifications]:</a> $notifications_total</b>
<script type="text/javascript" src="clientscript/vbulletin_notifications_nopopups.js?v=$vboptions[simpleversion]"></script>
<script type="text/javascript"> vBulletin.register_control("vB_Notifications_NoPopups", "notifications"); </script>
<else />
<b><a href="{$channel_fix}private.php$session[sessionurl_q]">Private Messages</a>: $vbphrase[unread_x_nav_compiled], $vbphrase[total_x_nav_compiled].</b>
</if>


Only problem is the $vbphrase part doesn't seem to work....

--------------- Added 1234238099 at 1234238099 ---------------

OK, used parse_templates hook instead and it's all good. Cheers!

Dismounted
02-10-2009, 05:12 AM
As you've found out, the phrase variable does not exist at global_start yet.