News:

Wondering if this will always be free?  See why free is better.

Main Menu

[Trick] Auto Code Live Links

Started by Masterd, January 04, 2011, 07:47:11 AM

Previous topic - Next topic

Masterd

This is now packaged as a mod. 

http://custom.simplemachines.org/mods/index.php?mod=2881





I found an interesting mod request here:

http://www.simplemachines.org/community/index.php?topic=415773.0

So, I decided to share my code with you. This modification will turn every live link on your forum to a code.

SMF 1.1.x

For SMF 1.1.x use this mod:

http://custom.simplemachines.org/mods/index.php?mod=1724

SMF 2.0

Sources/Subs.php

Find:

array(
'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="bbc_link new_win" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
),
array(
'tag' => 'url',
'type' => 'unparsed_equals',
'before' => '<a href="$1" class="bbc_link new_win" target="_blank">',
'after' => '</a>',
'validate' => create_function('&$tag, &$data, $disabled', '
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_after' => ' ($1)',
),


Replace with this:

array(
'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['code'] . ' <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code href="$1" class="bbc_code">$1</code>',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
),
array(
'tag' => 'url',
'type' => 'unparsed_equals',
'before' => '<div class="codeheader">' . $txt['code'] . ' <a href="#" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code href="$1" class="bbc_code">',
'after' => '</code>',
'validate' => create_function('&$tag, &$data, $disabled', '
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_after' => ' ($1)',
),


Screenshot is in the attachment.

Masterd

Can someone move this to the Tips and Tricks board?

rakicko

#2
Masterd it looks good..and this is improved..but take a look this,but i have one wish..is there any way..when a people post a multible links.. like
link1,link2 etc..with this mod..i see line link1[code/][code]link2[code/] etc..and is there any way ..if there is a multiple links to become line
[code] link1
link2
[/code]

and the font is not like original.. take a look

Masterd

I'm currently working on my laptop, so I will check this for you on Friday. Can someone move this?

lucas-ruroken

Adk Portal 3.1 is coming....

Design your universe!

Mick.



Masterd

I modified the code in the first post. Problem with different font is solved.


Arantor

You should make it work on iurl tags as well.

Masterd

I will do that just after I add the support for custom boards.

Masterd

Can someone finally move this topic?


Advertisement: