Firefox PHP

Module: HTML in Messages

Posted by Maurice Makaay 
Re: Module: HTML in Messages
October 23, 2009 05:49PM
I got some similar requirements like Rob Granger and did a small hack being new to php... I want only one user to post html so.... modified the default html plugin of phorum as below...

Language: PHP
foreach($data as $message_id => $message) { -->>> if ($message["user_id"]==2) <<<-- { if(isset($message["body"])) { $body = $message["body"];

It seems to work
Re: Module: HTML in Messages
November 12, 2009 05:23PM
Hi

I have added this to my forum and it works a treat bar for one problem - it is ignoring the new window commands. How can I make all links open in a new window?

Regards

My Phorum
Re: Module: HTML in Messages
November 12, 2009 05:37PM
Try adding this javascript (adapted from my Post Previews module) to the end of your read.tpl template file:

Language: Javascript
<script type="text/javascript"> function assign_foreign_url_targets() { anchors = document.getElementsByTagName("a"); for (i in anchors) { if (anchors[i].href) { ahref = anchors[i].href; if (!ahref.match("http://ukshopping.hopto.org")) { anchors[i].target = "_blank"; } } } }   assign_foreign_url_targets();   </script>

Basically, every url which does not link to your site will get the _blank target added via javascript.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: HTML in Messages
November 12, 2009 06:16PM
Works a treat - thanks!
Re: Module: HTML in Messages
November 24, 2009 01:46PM
Hi

Is there a way to add an extra domain to this code?

Language: PHP
<script type="text/javascript"> function assign_foreign_url_targets() { anchors = document.getElementsByTagName("a"); for (i in anchors) { if (anchors[i].href) { ahref = anchors[i].href; if (!ahref.match("http://ukshopping.hopto.org")) { anchors[i].target = "_blank"; } } } }   assign_foreign_url_targets();   </script>

I just noticed that my top links are all opening new windows as they are pointing to a different domain when reading the post.

Regards
Bluesplayer
Re: Module: HTML in Messages
November 24, 2009 02:05PM
To skip multiple domains, try:
if (!ahref.match("http://ukshopping.hopto.org") && !ahref.match("http://myothersite.com") ) {
You can add as many
&& !ahref.match("http://myothersite.com")
as you need.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: HTML in Messages
November 24, 2009 02:22PM
Works great! Thanks
Re: Module: HTML in Messages
November 24, 2009 03:16PM
Oops there is a problem with the code. It seems that only the 2nd site is working. The code is ignoring the first site now!

Language: PHP
if (!ahref.match("http://ukshopping.hopto.org") && !ahref.match("http://myothersite.com") ) {

Shouldn't the code be 'or' or something?
Re: Module: HTML in Messages
November 24, 2009 03:27PM
A couple of questions:
First, this if clause is designed to ignore to the listed sites, thus the "and" is necessary (ignore site 1 links and site 2 links and . . .) so can I assume that by "working" for the second site you mean that the links to that site are being ignored by this code and by "ignoring the first site" you mean that links to the first site are actually not being ignored and thus opening in a new window?

Second, I noticed that in other posts you have changed your sites domain from the ukshopping site to bluesplayer-shops. Did you change this bit of code to reflect the new domain?


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: HTML in Messages
November 24, 2009 03:32PM
1st Question: Yes the first site is opening new windows - 2nd site is ok.

2nd Question: Yes I altered the domain name as the UK Shopping was to be a separate site initially but on reflection I decided to use the same look as my main site and incorporate the shopping into it. The new name has bluesplayer in it so it doesn't look so out of place. The UK Shopping domain still works though.

UPDATE: Apparently the UK Shopping domain doesn't work! I will sort that out now.

Working now. The domains are free ones off no-ip and I hadn't ticked the box on the software I have on my computer to update the ipaddress of the domain.

Another UPDATE!

Sorry! I can see now why you referred to UK Shopping as it was the domain on the first part of the code and not my new domain. Now I have altered the domain setting the code works! Doh! Cheers.



Edited 3 time(s). Last edit at 11/24/2009 03:46PM by Bluesplayer.
Sorry, only registered users may post in this forum.

Click here to login