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 04-04-2011, 10:08 PM
AusPhotography's Avatar
AusPhotography AusPhotography is offline
 
Join Date: Nov 2007
Location: Hobart & Adelaide .au
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Template mods in a plugin - template_compile

Based on this discussion... http://www.vbulletin.com/forum/showt...=1#post2138507

I've moved all our site template mods into a plugin hook@process_templates_complete which does this (proforma)
Code:
if (!empty($vbulletin->templatecache['TEMPLATE']))
{
    $vbulletin->templatecache['TEMPLATE'] = str_replace($findtext,$replacetext,$vbulletin->templatecache['TEMPLATE]);
}
It works quite well and we don't have a lot of modifications.
Note: If it's a special template like $header you apply the same code directly to the parsed $header variable.

BUT! the problem is that the code is executed every page load (digitalpoint's post above).
Ideally I should modify the template one at compile time via the hook@template_compile.

The problem I have is how to force a re-compile of the templates in the site database
a) when the product is 1st installed
b) maybe when a product upgrade occurs

Any suggestions on how to force a template re-compile for an array of template names?

It would ideally run on product installation and upgrade!


Thanks!
Reply With Quote
  #2  
Old 04-04-2011, 10:49 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Something like this maybe?

Code:
if (vB_Template::$template_usage['register'] OR vB_Template::$template_usage['register_rules'])
Reply With Quote
  #3  
Old 04-04-2011, 11:05 PM
AusPhotography's Avatar
AusPhotography AusPhotography is offline
 
Join Date: Nov 2007
Location: Hobart & Adelaide .au
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, but how does that force the template to be re-compiled?

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

Digital points advises by PM that I may have to do it long hand via compile_template and looping thru the templates and updating long hand.
I was hoping for a shortcut
Reply With Quote
  #4  
Old 04-21-2011, 05:21 AM
AusPhotography's Avatar
AusPhotography AusPhotography is offline
 
Join Date: Nov 2007
Location: Hobart & Adelaide .au
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Found a solution https://vborg.vbsupport.ru/showthrea...ication+System
Reply With Quote
  #5  
Old 05-06-2011, 09:40 AM
ZeroHour's Avatar
ZeroHour ZeroHour is offline
 
Join Date: Sep 2007
Location: Scotland
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

snoopytas: regarding template_compile, I am working with it heavily right now for a few mods so once done I will write some tips and tricks.
Reply With Quote
  #6  
Old 08-08-2011, 05:45 PM
thincom2000 thincom2000 is offline
 
Join Date: May 2006
Location: Bronx, NY
Posts: 1,205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem I see with template_compile template mods is that, unless the user is running Template Modification System, you would essentially be forcing the user's database to customize that template in each style. Once this happens, it is difficult to determine whether the user actually has other customizations in the template or not, at least not without an expensive 3-way comparison that uses many megabytes of memory. For users that don't have the template merger class (pre-vB4 users) or that are on shared hosting, we can't revert the changes reliably during a product uninstall, upgrade, or discovery of TMS since the last update.

For these reasons I think it is less intrusive for the user and less error prone if we just encourage users to use TMS, and if TMS is not present, to use the inefficient runtime cache edit.
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 09:58 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04618 seconds
  • Memory Usage 2,206KB
  • 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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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