vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=266280

str_replace help please
by HMBeaty
05 Jul 2011 01:08

Ok, this is my 1st time playing around with str_replace and I'm obviously doing SOMETHING wrong as my code isn't working lol

Basically what I'm trying to do, is turn this into an automatic template edit, and eventually do the same with most of my personal modifications which haven't and won't be released here. So no need to worry about if user x installs on a custom style, he/she may run into problems later. :)

Anyway, on with the codes :D

Currently, I have this in a plugin

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

Which probably isn't right, but a lot of the threads I've searched through for vB 4 str_replace are incomplete as far as an official WORKING answer.

Now, with the code above, I've tried using the hook locations:
Quote:

global_start
showthread_start
parse_templates
showthread_postbit_create
postbit_display_start
postbit_display_complete
showthread_complete
Which seem to be the most logical ones to use for this modification, but it still isn't working. So, to me, that HOPEFULLY narrows it down to my code not being correct.

So, my next question is, what's wrong with it? :confused:

/ str_replace noob :D

Adrian Schneider 05 Jul 2011 01:12

Templates get compiled when you save into actual PHP code, and evaluated before it gets to global_shutdown.

global_start (or vb4 equivalent)

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

See what that prints out, and you'll have to do str_replace() on that variable, rather than $output.


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

--------------- Added 05 Jul 2011 at 01:13 ---------------

Alternatively, you could probably do it all in PHP.

Once you've rendered it once, set $post['signature'] = '';

HMBeaty 05 Jul 2011 01:30

Quote:

Originally Posted by Adrian Schneider (Post 2216805)
Templates get compiled when you save into actual PHP code, and evaluated before it gets to global_shutdown.

global_start (or vb4 equivalent)

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

See what that prints out, and you'll have to do str_replace() on that variable, rather than $output.

That gave me a blank white page
Quote:

Originally Posted by Adrian Schneider (Post 2216805)
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

--------------- Added 04 Jul 2011 at 21:13 ---------------

Alternatively, you could probably do it all in PHP.

Once you've rendered it once, set $post['signature'] = '';

And you lost me there lol

Adrian Schneider 05 Jul 2011 01:39

Move that first plugin to global_complete (for example's sake). I always forget that the global_start one has output buffering which would give you the blank page.

Once you see the output from a compiled template, it will give you an idea on how to actually figure out what to put in $find and $replace.


For the alternate method, upon successfully displaying the signature once, you can empty that variable so it won't display again, rather than relying on the template edit.

postbit_display_start

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

Not tested, but may work.

HMBeaty 05 Jul 2011 01:51

Quote:

Originally Posted by Adrian Schneider (Post 2216816)
Move that first plugin to global_complete (for example's sake). I always forget that the global_start one has output buffering which would give you the blank page.

Once you see the output from a compiled template, it will give you an idea on how to actually figure out what to put in $find and $replace.

Sorry, guess I should've mentioned I tried global_complete too, and that too gave a blank page.

Quote:

Originally Posted by Adrian Schneider (Post 2216816)
For the alternate method, upon successfully displaying the signature once, you can empty that variable so it won't display again, rather than relying on the template edit.

postbit_display_start

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

Not tested, but may work.

Just tested and this DOES work. Thanks. :) Now just need an updated tutorial for str_replace for vB 4 lol

Boofo 05 Jul 2011 02:57

Look how I did it here:

http://www.vbulletin.org/forum/showthread.php?t=259687

I did the mod for this for vb4.

MaryTheG(r)eek 05 Jul 2011 07:56

I don't think that:

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

is correct. You evaluate an expression there which maybe will cause endless loop by having $find there, which is also the first argument. I haven't seen all your code, but if you want to use that expression is better to add another variable before. eg:

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

Maria

Boofo 05 Jul 2011 08:20

In vb4, find doesn't work with if conditions very well. That is why your code below didn't work.


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



All times are GMT. The time now is 20:49.

Powered by vBulletin® Version 3.8.14
Copyright © 2020, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.