The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
So I was wondering, is it possible to write a code that will replace style variables?
I'm rewriting mod for username/displayname replacement, and I want it to be installed automatically. Regarding this: https://vborg.vbsupport.ru/showthread.php?t=302333 So I have variable {bbuserinfo.username} and I need to replace it with my custom code with <vb:if>. Any way to accomplish this with XML import, not editing templates manually? Hooks won't help here. |
#2
|
|||
|
|||
![]()
I'm not sure what you're asking. Where is the {bbuserinfo.username} that you want to replace?
|
#3
|
|||
|
|||
![]() Quote:
Is there a way to edit exsiting template when importing product? The simplest example: Let's say in template XXX we have this code: <div>test</div> I want to replace this in this template with: <div>other_test</div> While importing product, the template already exists, there are no template hooks there. Is there a way to do it with xml plugin install code for example? |
#4
|
|||
|
|||
![]()
There is a product that I believe does what you want, but if you use it you'd of course need anyone who uses your product to install it first, and I believe it puts a copyright notice on each page. In any case, it's here: www.vbulletin.org/forum/showthread.php?t=152931
What you can also do is write a plugin to do a search and replace on the template when it's in the template cache. If you make a plugin using hook parse_templates, the cached template will be in $vbulletin->templatecache['template_name']. But it's complicated by the fact that what is in the cache is actually php code that produces the template when eval'd. So you might be able to do a simple replacement if you just want to replace some text, but if you want to replace something that is inserted by a variable, it's more difficult to figure out what to use for the match and replacement text. |
#5
|
|||
|
|||
![]()
You don't understand me.
I am writing a product. To install it, I need to modify existing vBulletin template. The only way so far I know, was to use vBulletin template hooks and/or plugins system. My question is, is it possible to modify existing vBulletin template - FORUMHOME, to insert custom code inside? I know I can include whole forumhome template in the script and replace it, but if somebody edited it manually those changes will be lost. EDIT: Yes, that's what I'm looking for more-less. So this is a plugin, there is no way to do that on "vanilla" vB? |
#6
|
|||
|
|||
![]()
I thought I understood. Or I guess I should say, if I didn't understand before, I still don't.
Anything is possible. The templates are stored in the database, so you could execute a query to change a template, then call the function to recompile it (since a compiled version is also stored in the database). Also, a forum might have more than one style, and each style may or may not have a separate version of that template, so you'd have to handle that. You'd also want to remove your change when the template is uninstalled. There isn't any support for doing this in vb, and I haven't heard of anyone actually doing it that way, but maybe you have a reason for doing it that way that I don't know about. I think the usual thing to do is to write code to modify the template cache so that it appears that the template has changed, even though it won't look like it's changed in the template editor. That also avoids the style issue and the uninstall issue. I described how to do that in my previous post. If I still don't understand, maybe someone else can help. |
#7
|
|||
|
|||
![]()
That is what I asked. Thank you for your answer, it helped a lot.
Last question, how is it done if there is no template hook to use at this specific place, and there is a need to insert own template variable/show something there? EDIT: Okay, found something like: Code:
$vbulletin->templatecache['threadadmin_editthread'] = str_replace('<div class="blockrow"> <label for="notes">', '<div>\' . $extrathreadfields . \'</div><div class="blockrow"> <label for="notes">', $vbulletin->templatecache['threadadmin_editthread']); |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|