vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Replace Word in Post - only HTML! (https://vborg.vbsupport.ru/showthread.php?t=222401)

BRotondi 09-03-2009 06:21 PM

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

Lynne 09-03-2009 08:14 PM

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.

BRotondi 09-04-2009 12:06 AM

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

Lynne 09-04-2009 12:32 AM

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.

Dismounted 09-04-2009 04:08 AM

Also, make sure you use the _complete hook, and not the _start hook. The post is not parsed yet at the latter.

BRotondi 09-04-2009 04:46 AM

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

Dismounted 09-04-2009 06:03 AM

Quote:

Originally Posted by BRotondi (Post 1879459)
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.

BRotondi 09-04-2009 06:50 AM

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...)

Dismounted 09-04-2009 08:24 AM

Quote:

Originally Posted by BRotondi (Post 1879489)
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?

BRotondi 09-04-2009 09:22 AM

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


All times are GMT. The time now is 02:48 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01497 seconds
  • Memory Usage 1,730KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete