vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   plugin or product to delete a part of code of templates? (https://vborg.vbsupport.ru/showthread.php?t=267792)

cloferba 08-01-2011 08:13 PM

plugin or product to delete a part of code of templates?
 
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 -

PHP Code:

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

PHP Code:

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:

Code:

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

PHP Code:

echo $vbulletin->templatecache['newthread']; exit; 

In your case, you would use this:

PHP Code:

$vbulletin->templatecache['newthread'] = str_replace(
    
"' . $forumrules . '",
    
'',
    
$vbulletin->templatecache['newthread']
); 

But since $forumrules is a variable containing a rendered template, you can empty it instead.

PHP Code:

$forumrules ''

Cheers

cloferba 08-08-2011 06:30 PM

Quote:

Originally Posted by Adrian Schneider (Post 2230982)
You need to find/replace compiled code. If the enter the following, you can see what the compiled code looks like:

PHP Code:

echo $vbulletin->templatecache['newthread']; exit; 


where should i enter that?

--------------- Added [DATE]1312832742[/DATE] at [TIME]1312832742[/TIME] ---------------

Quote:

Originally Posted by Adrian Schneider (Post 2230982)
PHP Code:

$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 :(


All times are GMT. The time now is 02: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.01011 seconds
  • Memory Usage 1,746KB
  • 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
  • (1)bbcode_code_printable
  • (7)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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