Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2011, 08:13 PM
cloferba cloferba is offline
 
Join Date: Apr 2009
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 08-02-2011, 05:23 AM
setishock setishock is offline
 
Join Date: Feb 2008
Location: Houma, La.
Posts: 1,177
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 08-02-2011, 05:44 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 08-03-2011, 03:09 PM
cloferba cloferba is offline
 
Join Date: Apr 2009
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 08-08-2011, 06:00 PM
cloferba cloferba is offline
 
Join Date: Apr 2009
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 08-08-2011, 06:12 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #7  
Old 08-08-2011, 06:30 PM
cloferba cloferba is offline
 
Join Date: Apr 2009
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Adrian Schneider View Post
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 View Post
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
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 02:40 PM.


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.04482 seconds
  • Memory Usage 2,242KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete