Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 09-03-2009, 07:21 PM
BRotondi BRotondi is offline
 
Join Date: Sep 2008
Location: Zurich
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Replace Word in Post - only HTML!

Hello!

I want to replace e.g. every xxx to yyy - but only in the HTML-Output. This means: If someone posts "We show you xxx." then the browser will show "We show you yyy.", but if he presses "Edit post" the Editor (WYSIWYG and Text) will still give him "We show you xxx."

I tried different things, e.g. a Plug-In for bbcode_parse_complete:
PHP Code:
$text str_replace('xxx''yyy'$text); 
But this will change also the text for the editor.

How can I do this correct?

=> I don't need a plugin! This is a study for a more complex problem: Replace </br>-breaks with <p>-paragraphs which needs much more programming, since every [ code]...[ /code] needs his <p>...</p> etc.

Of course, if there exists allready a br-to-p-solution I'm even happier .

Thanks for any help!
Bruno
Reply With Quote
  #2  
Old 09-03-2009, 09:14 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I use a str_replace statement on my site that only effects the html output. I use the postbit_display_complete hook location to do it.
Reply With Quote
  #3  
Old 09-04-2009, 01:06 AM
BRotondi BRotondi is offline
 
Join Date: Sep 2008
Location: Zurich
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This sounds good! Which var do I have to change? $text has no effect... (or how can I find out this myself. Is there any documentation about that?)

Thanks!
Bruno
Reply With Quote
  #4  
Old 09-04-2009, 01:32 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The best way to find out what variables are used in a plugin is to find the plugin in the code and look at how variables are used around it. In this case, you need to use $this->post['message'] to modify the message text.
Reply With Quote
  #5  
Old 09-04-2009, 05:08 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Also, make sure you use the _complete hook, and not the _start hook. The post is not parsed yet at the latter.
Reply With Quote
  #6  
Old 09-04-2009, 05:46 AM
BRotondi BRotondi is offline
 
Join Date: Sep 2008
Location: Zurich
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your help! This works fine .

Does this mean, that there exists almost no documentation about hooks, variables etc. and search & ask in this forum is the best way of research?

I'm searching now for the correct hook and variable to do the same when pressing "preview".

Thanks for any help!
Bruno
Reply With Quote
  #7  
Old 09-04-2009, 07:03 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BRotondi View Post
Does this mean, that there exists almost no documentation about hooks, variables etc. and search & ask in this forum is the best way of research?
There are many articles available here on vBulletin.org which cover some "common" tasks.
Reply With Quote
  #8  
Old 09-04-2009, 07:50 AM
BRotondi BRotondi is offline
 
Join Date: Sep 2008
Location: Zurich
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, I have seen them and more on vBulletin-german.org. But some Kind of Reference would habe been nice .

Do you know which hook is executed after parsing the "Preview"?

Bruno
(I'm trying the ones in editpost.php right now...)
Reply With Quote
  #9  
Old 09-04-2009, 09:24 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BRotondi View Post
Do you know which kook is executed after parsing the "Preview"?
Are you talking about the page you see after clicking "Preview Post" in newreply.php?
Reply With Quote
  #10  
Old 09-04-2009, 10:22 AM
BRotondi BRotondi is offline
 
Join Date: Sep 2008
Location: Zurich
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes... There are multiple hooks there and since I'm also not sure which variable needs the search & replace, trial and error is difficult...

Bruno
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 03:04 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10519 seconds
  • Memory Usage 2,241KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete