This is now packaged as a mod.
http://custom.simplemachines.org/mods/index.php?mod=2881 (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 (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 (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.
Can someone move this to the Tips and Tricks board?
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
I'm currently working on my laptop, so I will check this for you on Friday. Can someone move this?
good tip ;)
Cool man ;)
Thanks! :D
I modified the code in the first post. Problem with different font is solved.
This is now packaged as a mod.
http://custom.simplemachines.org/mods/index.php?mod=2881 (http://custom.simplemachines.org/mods/index.php?mod=2881)
You should make it work on iurl tags as well.
I will do that just after I add the support for custom boards.
Can someone finally move this topic?