Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 16 Sep 2013, 21:55
create365 create365 is offline
 
Join Date: Aug 2013
replace variables in style with xml

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: http://www.vbulletin.org/forum/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.
Reply With Quote
  #2  
Old 17 Sep 2013, 11:21
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I'm not sure what you're asking. Where is the {bbuserinfo.username} that you want to replace?
Reply With Quote
  #3  
Old 19 Sep 2013, 14:15
create365 create365 is offline
 
Join Date: Aug 2013
Originally Posted by kh99 View Post
I'm not sure what you're asking. Where is the {bbuserinfo.username} that you want to replace?
Let's say it's in XXX template. I need to replace template variables in existing templates. Never done that with plugins, I only used template hooks and insert new templates.

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?
Reply With Quote
  #4  
Old 19 Sep 2013, 15:27
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #5  
Old 24 Sep 2013, 14:41
create365 create365 is offline
 
Join Date: Aug 2013
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?
Reply With Quote
  #6  
Old 24 Sep 2013, 16:02
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #7  
Old 25 Sep 2013, 14:49
create365 create365 is offline
 
Join Date: Aug 2013
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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So that is what I wanted. Not a nice way, so I wanted to ask if there is other option to achieve this. But apparently there is not.

Last edited by create365; 25 Sep 2013 at 16:26.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 16:31.

Layout Options | Width: Wide Color: