Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Manage Templates
Oblivion Knight
Join Date: May 2002
Posts: 1,757

Sheffield, UK
by Oblivion Knight Oblivion Knight is offline 23 Oct 2005

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:

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

Replace xxxx 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 ' and wrap a second template name with 's. You should have something like this:

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

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:

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

Replace xxxx 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:

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

Replace yyyy with the phrase variable.
Views: 11056
Reply With Quote
Comments
  #2  
Old 28 Oct 2005, 16:07
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Real name: Josh
Oh man thank you very much! I was on my way to request this as a tutorial.
Reply With Quote
  #3  
Old 28 Oct 2005, 16:16
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Real name: Andreas
If you are going to cache only one Template,


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

might be better than array_merge().
Reply With Quote
  #4  
Old 28 Oct 2005, 16:31
Oblivion Knight's Avatar
Oblivion Knight Oblivion Knight is offline
 
Join Date: May 2002
Real name: Andy
True, but using the array_merge() function allows additional templates to be added more easily.
Reply With Quote
  #5  
Old 10 Nov 2005, 18:41
dutchbb dutchbb is offline
 
Join Date: Dec 2003
How do I put 'include' and 'eval' for additional templates in a hook please?
Ty
Reply With Quote
  #6  
Old 06 May 2006, 06:43
SaN-DeeP's Avatar
SaN-DeeP SaN-DeeP is offline
 
Join Date: Jun 2002
thanks for
Grouping Custom Templates in the Admin CP
Reply With Quote
  #7  
Old 11 May 2006, 15:50
T2DMan T2DMan is offline
 
Join Date: Apr 2004
Real name: Michael
Cache, then need to use the template

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') . '";');
__________________
Michael Brandon
Webmaster and owner of RenewedReflections Weight Loss Surgery Forum
Reply With Quote
  #8  
Old 26 Feb 2007, 03:13
Chadi's Avatar
Chadi Chadi is offline
 
Join Date: May 2004
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?
__________________
...............................
Talk Jesus Forums: Christian Chat
games . chat . gallery . bible . videos

Last edited by Chadi; 26 Feb 2007 at 03:24. Reason: Automerged Doublepost
Reply With Quote
  #9  
Old 25 Sep 2008, 00:12
pritesh_shah83 pritesh_shah83 is offline
 
Join Date: Jun 2008
Real name: Pritesh
Grouping custom templates does not work for me

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 25 Sep 2008, 05:08
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
Do you actually have a template prefixed with that prefix?
__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #11  
Old 25 Sep 2008, 16:57
pritesh_shah83 pritesh_shah83 is offline
 
Join Date: Jun 2008
Real name: Pritesh
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
  #12  
Old 29 Jan 2009, 02:06
mikem1981 mikem1981 is offline
 
Join Date: Apr 2008
Real name: Michael
Group Custom Templates the Easy Way

[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
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
  #13  
Old 25 Oct 2009, 17:51
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Real name: Emily
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?


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

Works


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

Does NOT work
__________________
Just a placeholder.
Reply With Quote
  #14  
Old 19 Dec 2010, 14:51
Davidinh Davidinh is offline
 
Join Date: Apr 2005
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

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

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
  #15  
Old 19 Dec 2010, 20:55
Digital Jedi's Avatar
Digital Jedi Digital Jedi is offline
 
Join Date: Oct 2006
Real name: Mark Daniel Martinez
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

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

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:


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

Not tested, but should work.
__________________
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 14:56.

Layout Options | Width: Wide Color: