Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 10 Dec 2009, 10:16
mme42 mme42 is offline
 
Join Date: Feb 2009
Excluding Certain Forums for a Simple str_replace Filter Plug

I've been trying to write a simple filter plug-in to replace certain host/domain names with a message for certain forums only.

I actually started trying to replace the whole hyperlinked URLs or even plain text links with a regular expression. But, it's a bit over my head. And, after asking about it over at Stackoverflow, I've gotten the idea that there might be a better way to do it even if I figured out the REGEX to use. So, until I can begin to understand that stuff more, I've decided to just start with a simple str_replace to at least filter the domain part.

I have the filter part working fine, but I'm not sure how to exclude certain forums. There are less forums that I'd like to exclude than include, so I went about it from perspective of excluding them. I'm not sure if I'm using the right variable for the forum ID or using it in the right way. Here's what I have so far:


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


The hook location is postbit_display_complete and the execution order is 5 if that matters. So, I'm looking for the correct php forum ID variable and the correct way to use it in this situation if anybody can help.

Thanks.
Reply With Quote
  #2  
Old 10 Dec 2009, 13:57
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I think what you want is something like:


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


ETA: ...and you probably don't need the forum numbers in quotes.

Last edited by kh99; 10 Dec 2009 at 13:59. Reason: Auto-Merged DoublePost
Reply With Quote
  #3  
Old 10 Dec 2009, 14:23
mme42 mme42 is offline
 
Join Date: Feb 2009
Hmm. Thanks. I've now tried that, but it's still replacing in all sections. I tried with and without the quotes on the forum ID numbers.

This may be a silly question, but I don't need an ELSE do I? As in "IF it's not one of these forums use str_replace ELSE do nothing." Or, what else could be causing this not to work?
Reply With Quote
  #4  
Old 10 Dec 2009, 14:33
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Sorry, I did it again - I missed the fact that you are using "postbit_display_complete", so $foruminfo isn't visible there. But I think it has the same info in $forum, so try $forum['forumid'].
Reply With Quote
  #5  
Old 10 Dec 2009, 14:57
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Since you are using postbit_display_complete, if $forum['forumid'] doesn't work, try $this->forum['forumid']
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #6  
Old 10 Dec 2009, 14:57
mme42 mme42 is offline
 
Join Date: Feb 2009
Yep, that worked ($forum['forumid']) . Thanks so much! And thanks Lynne, I'll that in mind in case I need it.

Also, I get the impression that I should/could be using a different hook location? Or, what would be the other options postbit_display_start? And, is there any difference/effect?
Reply With Quote
  #7  
Old 10 Dec 2009, 15:46
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
If you are trying to filter the posts, then you should use a postbit_* hook location. I think if you used the start one, it may be too soon to do what you want. But you can try it and see on a test site.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
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 00:50.

Layout Options | Width: Wide Color: