Do you need the first plugin as well when using that code Paul?
I'm actually trying to do this... My goal is to have a template custom_header with a variable $custom_header which will contain all of the code from $header with a slight change (removing code for a right column and a different logo) for a CMPS home page... 1.) I do add new template, and put the code I want in it, saving it as custom_header. It now appears under "Custom Templates" 2.) I make a plugin with Quote:
3.) I add the plugin "globaltemplates[] = 'custom_header';" starting in cache template I enable both. I get error:Parse error: syntax error, unexpected '[' in /home/uninsta1/public_html/bu/forums/global.php(346) : eval()'d code on line 55 Right above the logo in ALL pages (not just CMPS...) Shortly thereafter forums don't show and errors occur in functions.php as well. I disable plugins. What should I try next? |
if you don't put $ before globaltemplates[], that won't work...
|
Oh god, this is confusing. Is there any way of explaining this to someone illiterate in the technical coding world?
I want to incorporate my custom template into the forum and $mycustomtemplate isn't working. Edit: Sorry for this post, I am an idiot. Worked it out. GREAT tutorial, this is EXACTLY what I was looking for ^_^ |
Quote:
A followup please: what exactly is "the technically best" way to do it? Thanks. |
I have this working completely, except in my hook I have $myvar = "test";
Now in my header template I have : $myvar Nothing happens. how can I get $myvar to be replaced with the dynamically created value from the hook? |
Compliments to Kerry-Anne for posting this.
I'm new to vB, but a long time PHP guru and forum admin (including uBB and phpBB). After reviewing some of the replies here I wish to add that the information presented here is not simply copy/paste, and requires basic knowledge of PHP as well as the hook and template system of vB. I noticed some of the more experienced PHP developers making suggestings and fixes here. I concur and wish to expand on that. I tried the procedure, and with a few minor corrections got it to work with less overhead simply by optimizing the commands (using advice posted earlier plus new advice from me): I can sum it up in 4 easy steps (vb 3.6.7+): 1) Create a custom template, i.e. "mytemplate" for purposes of these instructions Put in there "Hello World!" or any HTML so you know its working when it displays. 2) Add a new plugin, suggested name is "mytemplate_plugin" for easy reference Pick hook as "global_start" if you want your template available in any other, or select the appropriate hook depending on where you want your template to display. The latter is the better choice if you are customizing a specific feature of vB. Set plugin PHP code: $mytemplate_plugin = fetch_template('mytemplate_plugin_home'); 3) Create another plugin, suggested name is: "Cached - mytemplate_plugin" Pick hook as "cache_template" (located within vBulletin; General hooks in pulldown) Set plugin PHP code: $globaltemplates[]='mytemplate_plugin'; 4) In whatever template you wish (based on step 2) place the variable $mytemplate_plugin where you want your custom template to display. If successful, you'll see your "Hello World!" or your HTML as in step 1. Folks, that's all there is to it. Notice no need for eval or array_merge. This approach follows a simple naming convention that's easy to understand long after you implement and forget, and uses the most efficient PHP to get the job done, and will work perfectly without have to hack any native vB code. Yes, there are a million ways to skin a cat, this is one, but if you start doing alot of customization of this type, keeping the naming convention and optimizing the PHP code will save valuable server resources. Compliments to all who posted. Thanks for your time and if I missed something, please let me know. -jim |
Quote:
I want to be able to eval it in a single plugin, and make that template available to absolutely every other template - is there a way I can do that with a single hook? |
This is just what i have been looking for. I now have my affiliates on a seperate template from my forum home :D
|
Like Jingman stated - none of your solutions working if new template is added to FORUMDISPLAY, no matter of the hook location...
Any other thoughts? Thanks |
Both Methods, original and that of iVox, seem to make my template appear, however they do not seem to parse the template. I have conditionals in my template, and they appear like ".(($post[field5]) ? (" on the page.
What can be done to fix this? |
All times are GMT. The time now is 03:04 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|