Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 05 Jul 2011, 01:08
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Real name: Brooks
Red face str_replace help please

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

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:
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?

/ str_replace noob
__________________
"Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time!"
"It's important to only think about what you desire, not what you fear to achieve your ultimate goal!!
Reply With Quote
  #2  
Old 05 Jul 2011, 01:12
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
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'] = '';
__________________
Sr Software Developer / Tech Lead
Reply With Quote
  #3  
Old 05 Jul 2011, 01:30
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Real name: Brooks
Originally Posted by Adrian Schneider View Post
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
Originally Posted by Adrian Schneider View Post
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
__________________
"Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time!"
"It's important to only think about what you desire, not what you fear to achieve your ultimate goal!!
Reply With Quote
  #4  
Old 05 Jul 2011, 01:39
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
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.
__________________
Sr Software Developer / Tech Lead
Reply With Quote
  #5  
Old 05 Jul 2011, 01:51
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Real name: Brooks
Originally Posted by Adrian Schneider View Post
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.

Originally Posted by Adrian Schneider View Post
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
__________________
"Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time!"
"It's important to only think about what you desire, not what you fear to achieve your ultimate goal!!
Reply With Quote
  #6  
Old 05 Jul 2011, 02:57
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
Look how I did it here:

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

I did the mod for this for vb4.
Reply With Quote
  #7  
Old 05 Jul 2011, 07:56
MaryTheG(r)eek MaryTheG(r)eek is offline
 
Join Date: Oct 2006
Real name: Maria
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
Reply With Quote
  #8  
Old 05 Jul 2011, 08:20
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
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.

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:57.

Layout Options | Width: Wide Color: