MyBB Community Forums

Full Version: NoFollow Plugins - How Come None Works?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
There are 3 available plugins that promise to add rel="nofollow" tags to external links, yet none of them actually does. One of the plugins is more complex (SEO package) which fails to append this tag to outgoing links as well. What's the deal there? More complex plugins work fine, how come there is not a single one that would reliable perform such seemingly simple task?

As an alternative - could someone who's familiar with internal structure advise which file is to be modified to have each external link appended with rel="nofollow" tag (on top of currently used target="_blank" which is BTW no longer a valid XHTML)?
(2009-08-29, 10:56 AM)Tranny Wrote: [ -> ](on top of currently used target="_blank" which is BTW no longer a valid XHTML)
It's still valid in XHTML Transitional. MyBB isn't complying with XHTML Strict.

I'm assuming you only want external links that users post. The code is in the parser - you just need a plugin which checks whether the link specified points to an external resource, and if so, add the rel="nofollow" attribute.
yeah, I want URLs posted by members in forums to have a nofollow attribute added to it on top of regular _blank attribute which is added to each of the URLs posted. None of the plug in delivers. I would like to hard code it instead. Which file do I need to modify?
<?php



$plugins->add_hook("postbit", "nofollow_do");

$plugins->add_hook("member_profile_end", "nofollow_profile_do");



// Plugin Info

function nofollow_info()

{

	$return =  array(

		"name" => 'NoFollow Links',

		"description" => 'Add NoFollow to user posted links',

		"website" => "http://mods.mybboard.net",

		"author" => "Santiago Dimattia",

		"authorsite" => "http://www.teleportz.com.ar",

		"version" => "1.0",

	);
	
	return $array;

}



function nofollow_activate()

{

	// Add code to postbit_www template

	require MYBB_ROOT."/inc/adminfunctions_templates.php";



	find_replace_templatesets('postbit_www', '#<a\s#', '<a <!-- NoFollow -->');

}



function nofollow_deactivate()

{

	// Remove code from postbit_www template

	require MYBB_ROOT."/inc/adminfunctions_templates.php";



	find_replace_templatesets('postbit_www', '#\<!--\sNoFollow\s--\>#is', '', 0);

}



function nofollow_do($post)

{

	global $mybb;



	// Min. post to have DO FOLLOW.

	$post_count = 15;



	if($post['postnum'] < $post_count)

	{

		// Add nofollow to post links

		$post['message'] = preg_replace('#<a\s#is', '<a rel="nofollow" ', $post['message']);



		// Add nofollow to USER URL & Signature links

		$post['button_www'] = preg_replace('#\<!--\sNoFollow\s--\>#is', 'rel="nofollow" ', $post['button_www']);

		$post['signature'] = preg_replace('#<a\s#is', '<a rel="nofollow" ', $post['signature']);

	}

	else

	{

		// Delete <!-- NoFollow --> comment from USER URL

		$post['button_www'] = preg_replace('#\<!--\sNoFollow\s--\>#is', '', $post['button_www']);

	}



	return $post;

}



function nofollow_profile_do()

{

	global $mybb, $website;



	// Min. post to have DO FOLLOW.

	$post_count = intval($mybb->settings['nofollow_postcount']);

	

	if($post['postnum'] < $post_count)

	{

		// Add NoFollow on user webpage

		$website = preg_replace('#<a\s#is', '<a rel="nofollow" ', $website);

	}

}



?>

If you want ALL users have nofollow links, the best way to do it is hardcoding inc/class_parser.php.

If you want a more "custom" plugin (Group Exclusion, simple admin panel), try my nofollow plugin (You won't find it here, on MyBB)
It still doesn't ook like it takes care of links posted in profiles
Emmm, replace
$post_count = intval($mybb->settings['nofollow_postcount']);
With a number...
$post_count = 15;

If the template was edited correctly, it should work.