The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Insert Template Into Existing Template
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. |
#2
|
|||
|
|||
Plugin using hook location forumdisplay_complete:
Code:
$templater = vB_Template::create('myadtemplate'); $myadtemplate = $templater->render(); vB_Template::preRegister('FORUMDISPLAY', array('myadtemplate' => $myadtemplate)); Then edit your forumdisplay template and insert {vb:raw myadtemplate}. |
#3
|
||||
|
||||
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.
|
#4
|
|||
|
|||
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).
|
#5
|
||||
|
||||
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: Code:
<vb:if condition="in_array($foruminfo['forumid'], array(12,13,14,15,16,17,22))"> Ad Code Here </vb:if> |
#6
|
|||
|
|||
You need to register $foruminfo for use in your custom template, like this:
Code:
$templater = vB_Template::create('myadtemplate'); $templater->register('foruminfo', $foruminfo); $myadtemplate = $templater->render(); vB_Template::preRegister('FORUMDISPLAY', array('myadtemplate' => $myadtemplate)); |
#7
|
||||
|
||||
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: Code:
$templater = vB_Template::create('custom_forumsponsorads'); $templater->register('foruminfo', $foruminfo); $forumsponsorads = $templater->render(); vB_Template::preRegister('FORUMDISPLAY', array('forumsponsorads' => $forumsponsorads)); I am really starting to dislike how they changed things with vB. |
#8
|
|||
|
|||
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. |
#9
|
||||
|
||||
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.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|