Quick Nav:  Online Store   |   Login | Register

Replaceing text in active forums posts

Rate this topic:

Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
AuthorMessages
Nelson Fernandez
<100 Posts
Posts:50


07/17/2007 5:32 PM  

I want to let people post youtuvbe embedded videos in forum posts (Active Forums 3.6). To do this I decided that I could invent a tag that they could use. So I decided to use the following syntax:

[youtube⒯igHV0CwJk[/youtube]

The part in between the start and end tags is the id from youtube.

I have a javascript function that I feed the id to to display it in the post. I think if I try to post it here it will get changed but here goes a try:

<script language="Javascript">embedyoutube("91igHV0CwJk");</script>

 

My thought was to change replace [youtube] with the javascript tag up to the first quote of the embedyoutube() function, and also replace the [/youtube] tag with the text from the closing quote to the closing script tag.

However, this caused my site to go BOOM. With a very cryptic error about an XML parsing problem.

 

Here is the resulting rule as created in the config:

     
        youtube-start[youtube]embedyoutube(]]>
     

     
        youtube-end[/youtube]
     

(I hope the tags display properly)

 

Anyway, is there a bug that causes this, or is there a better way for me to handle the scenario I described?

 

Nelson Fernandez
<100 Posts
Posts:50


07/17/2007 5:38 PM  

The tags in the above post are being stripped.. let me summarize:

I want to take a tag like:

[mytag]  some text [/mytag]

 

and replace the tag protions with some javascipt that would result in "some text" being passed as a parameter. for example:

<script language="Javascript"> myfunction("some text") </script>

 

thanks

John Mitchell
Posts:3084


07/17/2007 5:47 PM  

This could probably be done, but you would need to use a different delimiter on your tokens.  ActiveForums encodes those square brackets on posts because that is what they use for token delimiters.


How about this:

The tag they post can look like this :  {youtube=igHV0CwJk}

Then the replacement rule can be:

 



SearchFor:  {youtube=(.*?)}

ReplaceWith:  <scriptlanguage="Javascript">embedyoutube("$1");</script>
Nelson Fernandez
<100 Posts
Posts:50


07/17/2007 8:35 PM  
works great as far as PB is concerned but AF has one more issue. AF uses part of the post body to set the meta tags content="" value. PB is doing its job on this part of the page and since it places a greater than as part of the replace, it causes this meta tag to close prematurely.

You can see this on my page here:
http://www.warbeats.com/Forums/tabid/59/view/topic/postid/39787/forumid/2/Default.aspx#39787

notice the very top of the page shows the text from the message.

Is there a way to have PB only process data within the body tags? Any other ideas?

Updating AF (dont know if its even fixable) is not an option because I havent upgraded that site to 4.5
John Mitchell
Posts:3084


07/17/2007 8:50 PM  

Ooops.

Ok, we can do even better than searching inside the page body tags and only target the post body.

Try this:



SearchFor:  (afpostbody.*?){youtube=(.*?)}

ReplaceWith:  $1<scriptlanguage="Javascript">embedyoutube("$2");</script>
Nelson Fernandez
<100 Posts
Posts:50


07/17/2007 8:57 PM  
John.... you are my hero.
John Mitchell
Posts:3084


07/17/2007 9:04 PM  
LOL, Regex is pretty powerful ain't it. ;)
Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
Forums >Snapsis Product Support >PageBlaster > Replaceing text in active forums posts



ActiveForums 3.7
Powered by: Snapsis Software