A better implementation of this feature is available in this thread, http://www.simplemachines.org/community/index.php?topic=510778.0.ZitatWarning:
FYI, this trick adds nofollow for all automatically parsed links (i.e. links that are not wrapped within url or iurl tags), irrespective of whether they're internal or external links.
To overcome that issue, I made a mod (its yet to be approved) and you may checkout the features of that mod in this link, http://www.simplemachines.org/community/index.php?topic=508093.
Tip/Trick to add "nofollow" option for external links. Do the following edits in
~/Sources/Subs.phpFind: 'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>',Replace: 'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="bbc_link" target="_blank" rel="nofollow">$1</a>',Find: 'tag' => 'url',
'type' => 'unparsed_equals',
'before' => '<a href="$1" class="bbc_link" target="_blank">',Replace: 'tag' => 'url',
'type' => 'unparsed_equals',
'before' => '<a href="$1" class="bbc_link" target="_blank" rel="nofollow">',How-To
- Use "url" tags for external links
- Use "iurl" tags for links within your website
This is awesome. Thank you so much for taking the time to post this xPandax.
Nicely done.
Reminds of Wikipedia. Their out links are the same. No follow.
Thank you. :)
Zitat von: BaoLePhuong in Juli 19, 2013, 10:51:56 NACHMITTAGS
This is awesome. Thanks. I love it :D
I'm glad to hear that and you're welcome.
I have my forum on a subdomain. Will this trick change the links that are linking to my domain to nofollow?
Zitat von: gr8shivam in Juli 21, 2013, 01:25:36 VORMITTAG
I have my forum on a subdomain. Will this trick change the links that are linking to my domain to nofollow?
Yes, it will for all links.
Since this trick, adds nofollow for all automatically parsed links, irrespective of whether they're internal or external links, I made a mod that differentiates the internal links from external links and
- automatically adds "iurl" tag for internal links, so that internal links are opened in the same window
- automatically adds "nofollow" only for external links
Check this thread, http://www.simplemachines.org/community/index.php?topic=508093. Feedback appreciated. Thanks.
My script code looks different for a version SMF 2.0.4:
),
array(
'tag' => 'iurl',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="bbc_link">$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' => 'iurl',
'type' => 'unparsed_equals',
'before' => '<a href="$1" class="bbc_link">',
'after' => '</a>',
'validate' => create_function('&$tag, &$data, $disabled', '
if (substr($data, 0, 1) == \'#\')
$data = \'#post_\' . substr($data, 1);
elseif (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
Zitat von: SKSLink.com in August 03, 2013, 02:11:18 NACHMITTAGS
My script code looks different for a version SMF 2.0.4:
You searched for
'tag' => '
iurl',
You should actually search for 'tag' => 'url',
FYI, this trick adds nofollow for all automatically parsed links, irrespective of whether they're internal or external links.
Nice tip, my friend. :)
Thank you very much.
Thanks for the knowledge.
Thank you very much.
This is great. And really useful. I love it.
A better implementation of this feature is available in this thread, http://www.simplemachines.org/community/index.php?topic=510778.0.
Sorry for the huge bump, but I had been struggling with making external links nofollow and internal ones followed, so I thought I would drop in and let everybody know how I did it.
1. Do what OP says. All links will be nofollow.
2. In Display.template.php of your template add the following code after:
// Show the post itself, finally!
Or really anywhere before the post body is rendered. For this next bit of code, I am checking for my site (sep7agon.net). You should replace the "sep7agon" and "net" with your respective domain name/TLD.
// Do some filters for external links...
$temp_content = $message['body'];
$preg_pattern = '~<a\shref\s?=\s?"http([^\.]+)sep7agon\.net([^>]+)>~';
$temp_content = preg_replace_callback(
$preg_pattern,
function($match){
return str_replace('rel="nofollow"', '', $match[0]);
},
$temp_content
);
$message['body'] = $temp_content;
Thx
Neo_TE made a mod of this trick, does anyone have it please? I can't be bothered to make edits? :P Someone attach it here?
Went to the op link:
http://www.simplemachines.org/community/index.php?topic=510778.0
His Mod:
http://custom.simplemachines.org/mods/index.php?mod=3767
it says "Sorry but no mod was found"?
the mod was removed from the mod site and the package was removed. even if the package exists somewhere it cant be attached unless it has a license that allows it.
Zitat von: Wellwisher in Juli 25, 2016, 10:39:16 NACHMITTAGS
Neo_TE made a mod of this trick, does anyone have it please? I can't be bothered to make edits? :P Someone attach it here?
Went to the op link:
http://www.simplemachines.org/community/index.php?topic=510778.0
His Mod:
http://custom.simplemachines.org/mods/index.php?mod=3767
it says "Sorry but no mod was found"?
Found it, it's on Github and it's public domain software/ license:
https://github.com/LinuxPanda/SMF2.0Mod--Auto_-iurl-_For_Internal_Links_And_-nofollow-_For_External_Links
Interesting mod, will test it out when I have the time. :)