View Full Version : plugin or product to delete a part of code of templates?
cloferba
08-01-2011, 08:13 PM
i want to make my forum as fast as i can, so i would like to make a plugin to delete some parts of templates... does exists a way to do this?
imagine that in forumrules template i want to remove automatically the line
<h4 class="blockhead">{vb:rawphrase posting_rules}</h4>
this is because i have too many templates to manually edits them, if i could delete this line for example with a plugin i would save time
any help is appreciated :)
setishock
08-02-2011, 05:23 AM
Streamline queries.
However in a more humorous light, could you imagen if you had a bot that would look at your templates and edit out whatever you told it to. That would be sort of cool until you realize that it's only paying attention to class= and deleting all the text associated with it in every template. You would find your forum in shambles in no time at all.
We on the other hand would find you in a corner sucking your thumb babbling incoherently something about you should have done it yourself.
Adrian Schneider
08-02-2011, 05:44 AM
A few things...
Are you trying to speed up page generation, or page download/rendering? Deleting random bits from templates will help with the latter only.
If you have a ton of forums, or lots of stuff on your pages, then it totally makes sense to start stripping things out. However, doing it automatically takes a bit longer to prepare, so there isn't really any time saved - unless you plan on doing this across tons of different websites.
You can simply put stuff like in your plugin -
$vbulletin->templatecache['SOME_TEMPLATE'] = str_replace(
'<h4 class="blockhead">' . vB_Template_Runtime::parsePhrase("posting_rules") . '</h4>',
'',
$vbulletin->templatecache['SOME_TEMPLATE']
);You'll notice the find/replace must be compiled template code. You can just print out the template you want to look at to see what it looks like in the compiled format (assuming it's cached already) :
echo $vbulletin->templatecache['SOME_TEMPLATE'];
exit;Then start copy/pasting from there. Be careful with the escaping - sometimes it's not a simple copy/paste job (notably with the single quotes for array keys).
On our site, we use this method to automate stripping elements out, so we don't have to keep doing it for various styles. Sometimes you can simply force an option or show variable, so exhaust your options first.
This will probably cause a ton of confusion for non-devs who try to maintain the site later, so be sure to clearly document the plugin. Having it all centralized at least makes it easy to understand where its coming from.
Hope this helps :)
cloferba
08-03-2011, 03:09 PM
the problem is that vbulletin4 has too much boxes and elements that are not necessary needed, so i want to delete them automatically..
on every vb upgrade, my admincp tell me that i have to revert some templates.. (and in that template i have deleted somethings to make my forum load faster)
so i need to revert it and again delete the things i dont want.... and same with each vb upgrade..
i think this way (to delete automatically what i dont need) is the best way to avoid this constant edition every time i upgrade vb..
thanks :)
cloferba
08-08-2011, 06:00 PM
i have written this on the plugin:
$vbulletin->templatecache['newthread'] = str_replace(
'{vb:raw forumrules}',
'',
$vbulletin->templatecache['newthread']
);
it is executed on newthread_start
but it doesnt work
all what i want is to delete that part from the newthread template
Adrian Schneider
08-08-2011, 06:12 PM
You need to find/replace compiled code. If the enter the following, you can see what the compiled code looks like:
echo $vbulletin->templatecache['newthread']; exit;In your case, you would use this:
$vbulletin->templatecache['newthread'] = str_replace(
"' . $forumrules . '",
'',
$vbulletin->templatecache['newthread']
);But since $forumrules is a variable containing a rendered template, you can empty it instead.
$forumrules = '';
Cheers
cloferba
08-08-2011, 06:30 PM
You need to find/replace compiled code. If the enter the following, you can see what the compiled code looks like:
echo $vbulletin->templatecache['newthread']; exit;
where should i enter that?
--------------- Added 1312832742 at 1312832742 ---------------
$vbulletin->templatecache['newthread'] = str_replace(
"' . $forumrules . '",
'',
$vbulletin->templatecache['newthread']
);
no way...
i have put that code in a new plugin but forumrules are being shown :(
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.