Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Manage Templates
Oblivion Knight's Avatar
Oblivion Knight
Join Date: May 2002
Posts: 1,757

 

Sheffield, UK
Show Printable Version Email this Page Subscription
Oblivion Knight Oblivion Knight is offline 10-22-2005, 10:00 PM

Want to cache templates or group custom templates in the Admin CP without editing the source code? Of course you do! Want to know how to achieve this? Read on..



Caching Templates
This is probably NOT the best way of achieving this, however if you're wanting to effectively cache a template in an existing file (for example, the v3arcade award bits in showthread.php), this how to achieve this with a simple plugin.

Add a plugin to the following hook location:
vBulletin : General -> cache_templates

With the following code:
Code:
$globaltemplates = array_merge($globaltemplates, array('xxxx'));
Replace [high]xxxx[/high] with the template that you are wanting to cache.

It's as simple as that! Also, if you're wanting to cache multiple templates, simply add a comma after the last [high]'[/high] and wrap a second template name with [high]'[/high]s. You should have something like this:
Code:
$globaltemplates = array_merge($globaltemplates, array('xxxx', 'yyyy'));
Repeat as required..



Grouping Custom Templates in the Admin CP
Add a plugin to the following location:
vBulletin : General Administration -> template_groups

With the following code:
Code:
$only['xxxx'] = 'Group Name';
Replace [high]xxxx[/high] with the template prefix that you are wanting to group.

Once again, this is very easy to do. If you're wanting to do add multiple groups, add a second line below this one and do the same again. If you wish to use a phrase, use:
Code:
$only['xxxx'] = $vbphrase['yyyy'];
Replace [high]yyyy[/high] with the phrase variable.
Reply With Quote
  #12  
Old 09-25-2008, 02:57 PM
pritesh_shah83 pritesh_shah83 is offline
 
Join Date: Jun 2008
Location: Long Beach, CA
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The templates that I wish to group start with NewTemplategroup. And this is what I found:
Use newtemplategroup in lower-case as the array index, otherwise it doesn't work

// This works like a charm
$only['newtemplategroup'] = 'New Template group';

// This does not work
$only['NewTemplategroup'] = 'New Template group';

Thanks for the quick reply. I hope this helps someone
Reply With Quote
  #13  
Old 01-29-2009, 12:06 AM
mikem1981 mikem1981 is offline
 
Join Date: Apr 2008
Location: Spring Lake, NC 28390
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[quote=Oblivion Knight;803104]Want to cache templates or group custom templates in the Admin CP without editing the source code? Of course you do! Want to know how to achieve this? Read on..

Now in plain english the easiest way to do this step by step is:

Add a plugin to the following hook location:
Plugins & Products: Add New Plugin
step 1 example:
  • Product: vBulletin
  • Hook Location: template_groups
  • Title: TEST TEMPLATES
  • Plugin PHP Code: $only['testtemplate'] = $vbphrase['mytest'];
  • Plugin is Active:Yes
Next you want to add the Main Titles phrase of your Grouped Templates
step 2 example:
Languages & Phrases: => Phrase Manager => Add New Phrase
  • Phrase Type: GLOBAL
  • Product: Either your product or the default which is vBulletin
  • Varname: mytest
  • Text: TEST TEMPLATES
Now the last step is creating the template or templates
last step example:
Styles & Templates => choose your current style unless you have debug mode on, you can chooseMASTER STYLE => Add New Template
  • Product: vBulletin or Your Product
  • Style: Your current style unless you have debug mode on, you can chooseMASTER STYLE to make this template for all the styles
Quote:
Now remember to always have the prefix to what you have it set on in the plugin that you gave it, we already chose $only['testtemplate'].
  • Title: testtemplate_HOMEPAGE
  • Template: you can put your HTML/PHP or whatever code you like to put here. you can even say "hi!"
  • Click save and go see your new group of templates called "TEST TEMPLATES"

I still give credits to Oblivion Knight, however, this I would rather say because it is far more easier to do these step by step. Now that I have gave you a break down on how to accomplish this the easy way, please feel free to rep me. But please, this original tutorial was by Oblivion Knight, I just broke it down in PLAIN ENGLISH! Thanks!
Reply With Quote
  #14  
Old 10-25-2009, 03:51 PM
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Posts: 153
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For some reason when I did this with a prefix with an underscore (_) it did not work, but as soon as I took the underscore out it worked just fine.

From the examples above it would appear that some people have gotten it to work with an underscore in their prefix, but it's just not working for me in 3.8.

But the thing is, all of my vBa scripts have underscores in their template groups (adv_portal, adv_links), so I know it should work.

Any ideas?

PHP Code:
$only['cematyt'] = $vbphrase['trackyertees']; 
Works

PHP Code:
$only['cema_tyt'] = $vbphrase['trackyertees']; 
Does NOT work
Reply With Quote
  #15  
Old 12-19-2010, 12:51 PM
Davidinh Davidinh is offline
 
Join Date: Apr 2005
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hello vB experts

i need some help
i tried to add template into ad location section (template)
and i did exactly the tutor said
temlate group
Code:
 $only['ad_'] = $vbphrase['group_ad_location'];
then i created the template within prefix ad_

but seem not work the template i created it till outside of the ad location group

any suggestion will be appriciated

Sincerely,
Reply With Quote
  #16  
Old 12-19-2010, 06:55 PM
Digital Jedi's Avatar
Digital Jedi Digital Jedi is offline
 
Join Date: Oct 2006
Location: PopCulturalReferenceLand
Posts: 5,171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Davidinh View Post
hello vB experts

i need some help
i tried to add template into ad location section (template)
and i did exactly the tutor said
temlate group
Code:
 $only['ad_'] = $vbphrase['group_ad_location'];
then i created the template within prefix ad_

but seem not work the template i created it till outside of the ad location group

any suggestion will be appriciated

Sincerely,
Don't include the underscore. Just the prefix name:

Code:
 $only['ad'] = $vbphrase['group_ad_location'];
Not tested, but should work.
Reply With Quote
  #17  
Old 12-19-2010, 09:21 PM
Davidinh Davidinh is offline
 
Join Date: Apr 2005
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oh wow ... it works like champ

thanks so much .... Digital Jedi
Reply With Quote
  #18  
Old 01-24-2012, 10:44 PM
cowcowcow cowcowcow is offline
 
Join Date: Jul 2009
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did it on my custom templates using 'Postbit' to try and put my custom postbits into that category with the default postbits that comes with vbulletin.

but for some strange reason i now have two "Postbit Templates" instead with the exact same spelling lol

Code:
$only['menufortgm'] = 'Postbit';
$only['clanheaders'] = 'Postbit';
Any help would be great!
Reply With Quote
  #19  
Old 08-24-2012, 07:19 PM
ChiNa ChiNa is offline
 
Join Date: Jul 2012
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I started creating products, and I am stuck

Can I ask, the footer and header templates, can it be a part of caching, or can I use the caching on footer or header template... and which templates can be reffered to or as $globaltemplates...

Here is the HOOK for caching my template below:
<hookname>cache_templates</hookname>

and my PHPCODE:

$globaltemplates = array_merge($globaltemplates, array('MYCODENAME'));

and my replacement code:
if ($vbulletin->options['social_five_on'])
{
$replace = '$ad_location[ad_footer_start]';
$vbulletin->templatecache['footer'] = str_replace($replace,$replace.fetch_template('MYCODENAME'),$vbulletin->templatecache['footer']);

IS this done right?

by the way this is for vB3.8
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:47 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04328 seconds
  • Memory Usage 2,292KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (8)bbcode_code
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (9)post_thanks_box
  • (1)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete