vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Manage Templates (https://vborg.vbsupport.ru/showthread.php?t=99132)

Oblivion Knight 10-22-2005 10:00 PM

Manage Templates
 
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.

Snake 10-28-2005 02:07 PM

Oh man thank you very much! I was on my way to request this as a tutorial. :mad:

Andreas 10-28-2005 02:16 PM

If you are going to cache only one Template,

PHP Code:

$globaltemplates[] = 'xxxx'

might be better than array_merge().

Oblivion Knight 10-28-2005 02:31 PM

True, but using the array_merge() function allows additional templates to be added more easily.

dutchbb 11-10-2005 04:41 PM

How do I put 'include' and 'eval' for additional templates in a hook please?
Ty

SaN-DeeP 05-06-2006 04:43 AM

thanks for
Quote:

Grouping Custom Templates in the Admin CP

T2DMan 05-11-2006 01:50 PM

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') . '";');

Chadi 02-26-2007 01:13 AM

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?

pritesh_shah83 09-24-2008 10:12 PM

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

Dismounted 09-25-2008 03:08 AM

Do you actually have a template prefixed with that prefix?

pritesh_shah83 09-25-2008 02:57 PM

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 :)

mikem1981 01-29-2009 12:06 AM

[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!;)

Dax IX 10-25-2009 03:51 PM

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

Davidinh 12-19-2010 12:51 PM

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,

Digital Jedi 12-19-2010 06:55 PM

Quote:

Originally Posted by Davidinh (Post 2136338)
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.

Davidinh 12-19-2010 09:21 PM

oh wow ... it works like champ

thanks so much .... Digital Jedi

cowcowcow 01-24-2012 10:44 PM

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!

ChiNa 08-24-2012 07:19 PM

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


All times are GMT. The time now is 01:17 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02552 seconds
  • Memory Usage 1,776KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (3)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete