The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Modify template by install code
I want to do simple search/replace in the template on product install.
It works fine, however until it's re-saved manually changes are not visible. I guess I need to re-cache the template? How to solve this? Thanks in advance. |
#2
|
||||
|
||||
Why don't you just use the parse_templates hook and do it in the mod itself? I know of no way to do it on the actual install procedure of a mod.
|
#3
|
||||
|
||||
You don't want to actually change the master style. I think that would be a no-no.
|
#4
|
|||
|
|||
Thanks for you replies.
I've tried to do this in parse_templates but it won't work: Code:
$vsa_tlmu_rstr_s = '<a class="title'; $vsa_tlmu_rstr_r = '<a style="{vb:raw thread.vsa_tlmu_css}" class="title'; $vbulletin->templatecache["threadbit"] = str_replace($vsa_tlmu_rstr_s, $vsa_tlmu_rstr_r, $vbulletin->templatecache["threadbit"]); When I manually add Code:
style="{vb:raw thread.vsa_tlmu_css}" thread.vsa_tlmu_css is produced in threadbit_process hook. |
#5
|
||||
|
||||
vb 4 does it differently. Try this in the parse_templates or process_templates_complete hook:
Code:
require_once(DIR . '/includes/class_template_parser.php'); $parser = new vB_TemplateParser('<a class="title'); $parser->dom_doc = new vB_DomDocument($parser->fetch_dom_compatible()); $find = trim($parser->_parse_nodes($parser->dom_doc->childNodes())); $parser = new vB_TemplateParser('<a style="{vb:raw thread.vsa_tlmu_css}" class="title'); $parser->dom_doc = new vB_DomDocument($parser->fetch_dom_compatible()); $replace = trim($parser->_parse_nodes($parser->dom_doc->childNodes())); $vbulletin->templatecache['threadbit'] = str_replace($find, $replace, $vbulletin->templatecache['threadbit']); unset($find, $replace); |
3 благодарности(ей) от: | ||
Lynne, TheLastSuperman, Valter |
#6
|
|||
|
|||
Yes, it works.
You are genius. Thank You! Edit: It also works when added after my code in threadbit_process. |
#7
|
||||
|
||||
You had doubts?
And you are welcome, my friend. |
#8
|
||||
|
||||
thanks Boofo for your code it helped me too
|
#9
|
||||
|
||||
I expect residuals.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|