PDA

View Full Version : Auto edit templates?


masterross
03-21-2010, 04:21 PM
Hi guys can you help me with auto editing templates?

I've tried to use
preg_replace()

But seems I'm doing something wrong.
If you have some examples will be great.

Thx in advance!

TalkVirginia
03-21-2010, 09:12 PM
Hi guys can you help me with auto editing templates?

I've tried to use
preg_replace()

But seems I'm doing something wrong.
If you have some examples will be great.

Thx in advance!

Can you give a bit more info on what you're doing or trying to do?

masterross
03-22-2010, 01:12 AM
Hi

I'm trying to edit template reputationbit

So i put this in hook global start:
$search = 'test';
$replace = 'blablaa';

$vbulletin->templatecache['reputationbit'] = preg_replace("/$search/", $replace, $vbulletin->templatecache['reputationbit']);

But nothing's changed...

(of course $search = 'test' is just an example)

mikey1991
03-22-2010, 01:24 AM
Personally I use something like this;

$find = 'test';
$replace = 'blablaa';

$vbulletin->templatecache['reputationbit'] = str_replace($find,$find . $replace,$vbulletin->templatecache['reputationbit']);

worked for my postbit mods.

--------------- Added 1269224776 at 1269224776 ---------------

Also the hook is important. I put mine on showthread_start. If you put it on global_start, it will be running even when it is not needed, this impacts upon performance, however if you hook it into showthread_start, then it will only run on threads, which is where it is needed. :up:

TalkVirginia
03-22-2010, 01:34 AM
Hi

I'm trying to edit template reputationbit

So i put this in hook global start:
$search = 'test';
$replace = 'blablaa';

$vbulletin->templatecache['reputationbit'] = preg_replace("/$search/", $replace, $vbulletin->templatecache['reputationbit']);

But nothing's changed...

(of course $search = 'test' is just an example)

you might want to look at the following guide if you are inserting your own variables:
[HOW TO - vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)

I think a better hook would be reputation_start

mikey1991
03-22-2010, 01:38 AM
heh. didn't see this was vb4 discussions, haha.

masterross
03-22-2010, 11:05 AM
you might want to look at the following guide if you are inserting your own variables:
[HOW TO - vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)

I think a better hook would be reputation_start

This guide is my home page from the beginning :)

Anyway I tested all possible but no result.
So if anyone has some practical examples or know existing hack for vb4 using auto editing will be appreciated!