vBulletin Mods

The Official vBulletin Modifications Site

Insert Template Into Existing Template
by Rich
16 May 2012 11:54

I am so frustrated with the template system. I loved the days when $variable was used. I am completely lost on this new way of inserting templates into existing templates. I have read the article on variables and don't seem to be understanding it because it doesn't seem to be working for me.

All I want to do is add my ad code to the top of the forumdispaly template via calling another template.

Lets say the template were called "myadtemplate". How the heck do I get it to show at the top of the forumdisplay template below the navbar? I simply can't get it to display. I am trying to do this via plugins. I had no issues in the past when I could simply set the variable as $variable and eval the template.

Thanks for any help you can offer.

kh99 16 May 2012 12:45

Plugin using hook location forumdisplay_complete:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then edit your forumdisplay template and insert {vb:raw myadtemplate}.

Rich 16 May 2012 13:26

I appreciate the help kh99 but I attempted to use that code with no luck. I had used various deviations of that same code when I tried before as well.

kh99 16 May 2012 13:45

You're right, it doesn't work - the template name FORUMDISPLAY should be in all caps. I fixed the code above (which now seems to work for me).

Rich 16 May 2012 17:04

Thank you again. I can't believe I played with it for as long as I did and the entire time it was capitalization causing me problems. At least i had the code right at some point, lol.

That code works as expected but I am not certain I can actually use it now. lol It called my template as expected but when I added my conditionals based on forumid I didn't get any output. The conditional works fine within the forumdisplay template itself so I am guessing I need to either alter the condition since it is called from another template or I need to append the plugin to another hook.

This is the conditional:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

That works great in the forumdisplay tem[plate but ceases to work when it is called via the custom template. since I have blocks of ads being called based on foum ids I wanted to call them outside the forumdisplay template because of how large the template will be. If it isn't one thing, its another! lol

kh99 16 May 2012 20:59

You need to register $foruminfo for use in your custom template, like this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Rich 17 May 2012 13:10

Thanks kevin but that returns the following error.

Fatal error: Call to a member function register() on a non-object in /home/site/public_html/forumdisplay.php(1198) : eval()'d code on line 51

This is the exact plugin code I am using:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It is being executed at the forumdusplay_complete hook.

I am really starting to dislike how they changed things with vB.

kh99 17 May 2012 14:28

Hmm...I don't see why you'd get that error. When I first posted the code I had a typo in it where that register line had $template instead of $templater, but I fixed it and the code you posted doesn't have that. Is it possible you used my code before it was fixed (because you probably got emailed the original version)? I tried what you posted above and it doesn't give an error even though I don't even have that template.

I know what you mean, I've been a programmer pretty much my entire life and I found it frustrating at first. It makes a lot of sense after a while, but unfortunately that doesn't help people who just want to get something done.

Rich 17 May 2012 17:59

It does appear that I may have run it with the unedited version. I copy and pasted the code you wrote and just swapped the myadtemplate with my actual stuff since thats all I did the first time. It is up and running. Thank you very much.

All times are GMT. The time now is 23:37.

Powered by vBulletin® Version 3.8.14
Copyright © 2020, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.