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
  #2  
Old 10-28-2005, 02:07 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh man thank you very much! I was on my way to request this as a tutorial.
Reply With Quote
  #3  
Old 10-28-2005, 02:16 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you are going to cache only one Template,

PHP Code:
$globaltemplates[] = 'xxxx'
might be better than array_merge().
Reply With Quote
  #4  
Old 10-28-2005, 02:31 PM
Oblivion Knight's Avatar
Oblivion Knight Oblivion Knight is offline
 
Join Date: May 2002
Location: Sheffield, UK
Posts: 1,757
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

True, but using the array_merge() function allows additional templates to be added more easily.
Reply With Quote
  #5  
Old 11-10-2005, 04:41 PM
dutchbb dutchbb is offline
 
Join Date: Nov 2003
Posts: 899
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How do I put 'include' and 'eval' for additional templates in a hook please?
Ty
Reply With Quote
  #6  
Old 05-06-2006, 04:43 AM
SaN-DeeP's Avatar
SaN-DeeP SaN-DeeP is offline
 
Join Date: Jun 2002
Location: Mumbai, India
Posts: 1,195
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks for
Quote:
Grouping Custom Templates in the Admin CP
Reply With Quote
  #7  
Old 05-11-2006, 01:50 PM
T2DMan T2DMan is offline
 
Join Date: Apr 2004
Location: Auckland, New Zealand
Posts: 81
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To use a template, you need to make available the variable for that template, before it is used in another template - ie a new $adsense template used in navbar template.

first cache the template as described:
cache_template
$globaltemplates[] = 'adsense';

Then add it to a variable for use:
global_start
eval('$adsense = "' . fetch_template('adsense') . '";');
Reply With Quote
  #8  
Old 02-26-2007, 01:13 AM
Chadi's Avatar
Chadi Chadi is offline
 
Join Date: May 2004
Location: USA
Posts: 2,043
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you. It worked partially for some reason.

Plugin:

$only['quiz'] = 'Quiz';
$only['Display'] = 'Flashchat';
$only['Top_Posters'] = 'Top Posters';
$only['top_statistics'] = 'Top Statistics';
$only['vbfavorites'] = 'vBFavorites';
$only['zointstags'] = 'Zoints Tags';
$only['tutorial'] = 'Tutorial';

The ones that did not get picked up are:

$only['Display'] = 'Flashchat';
$only['Top_Posters'] = 'Top Posters';

The prefix are correct for sure.

Edit: prefix must be lowercase.

One more thing, how do I have the groups listed in alphabetical order?
Reply With Quote
  #9  
Old 09-24-2008, 10:12 PM
pritesh_shah83 pritesh_shah83 is offline
 
Join Date: Jun 2008
Location: Long Beach, CA
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried
$only['somegroup'] = 'Some Group';

I printed $only and it shows $only['somegroup'] => 'Some Group'

But, there is no group called Some Group in my Style Manager. Can you please help
Reply With Quote
  #10  
Old 09-25-2008, 03:08 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you actually have a template prefixed with that prefix?
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 08:06 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.05009 seconds
  • Memory Usage 2,293KB
  • 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
  • (4)bbcode_code
  • (1)bbcode_php
  • (1)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
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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