Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Wellwisher on June 22, 2015, 08:28:11 PM

Title: How to add "noindex" to one SMF forum topic/ thread?
Post by: Wellwisher on June 22, 2015, 08:28:11 PM
Hello there a way to add "noindex" to just one SMF forum topic?
Title: Re: How to add "noindex" to one SMF forum topic/ thread?
Post by: Kindred on June 22, 2015, 08:37:10 PM
no....
Title: Re: How to add "noindex" to one SMF forum topic/ thread?
Post by: All Colours Sam on June 22, 2015, 08:41:20 PM
There is no mod AFAIK but its simply a matter of adding a couple of lines into a source file.

On your Sources/Display.php find this:

// Add up unapproved replies to get real number of replies...

and add this before that:


if (!empty($topic) && $topic == 1)
$context['robot_no_index'] = true;


Where 1 is the topic ID you want to add the no index meta tag.
Title: Re: How to add "noindex" to one SMF forum topic/ thread?
Post by: Wellwisher on June 24, 2015, 02:12:27 PM
Quote from: Suki on June 22, 2015, 08:41:20 PM
There is no mod AFAIK but its simply a matter of adding a couple of lines into a source file.

On your Sources/Display.php find this:

// Add up unapproved replies to get real number of replies...

and add this before that:


if (!empty($topic) && $topic == 1)
$context['robot_no_index'] = true;


Where 1 is the topic ID you want to add the no index meta tag.

Thank you Suki and what if there's multiple topics? Can you seperate this with commas i.e:


if (!empty($topic) && $topic == 1,2,3,4,5,6,7,8,9,10) <--- extreme example but you know..   :)
$context['robot_no_index'] = true;


Thank you again mate.  :) I just wanted to do one topic but I am curious.
Title: Re: How to add "noindex" to one SMF forum topic/ thread?
Post by: Kindred on June 24, 2015, 02:20:16 PM
no...   to do that, you would need to make an array and use slightly different code...
Of course, this begs the question... Why are you trying to do this, anyway?
Title: Re: How to add "noindex" to one SMF forum topic/ thread?
Post by: Wellwisher on June 24, 2015, 03:06:31 PM
Quote from: Kindred on June 24, 2015, 02:20:16 PM
no...   to do that, you would need to make an array and use slightly different code...
Of course, this begs the question... Why are you trying to do this, anyway?

Hello Kindred

Sometimes, members will post things (basically copying and pasting content from their websites/ blogs) on forums to gain higher rankings, exposure, make them sound legitimate or something. Whilst at times, this may be genuine, I want to ability to stomp this kind of activity out.
Title: Re: How to add "noindex" to one SMF forum topic/ thread?
Post by: All Colours Sam on June 24, 2015, 03:17:21 PM
In that case, it might be better to check against the user/membergroup ID instead of the topic ID.

That is, if an user does that, put him/her on a special group and then check if whoever posting belongs to that group, if so, set the no index tag.

Of course this will flag all of the user's post with the no index tag and not just the ones with copy/paste content, if your suers only does that on certain boards you can limited the check to those boards too.
Title: Re: How to add "noindex" to one SMF forum topic/ thread?
Post by: Kindred on June 24, 2015, 03:23:44 PM
hmmmm.... Well, you seem to be attempting to programmatically handle something which (IM) is bets handled by simple rules and then penalties for breaking the rules...



instead of doing this... and updating it every time someone does that -- why not just delete the thread in question and warn the user not to do that? If the user continues, then the user gets banned.   Problem solved!
Title: Re: How to add "noindex" to one SMF forum topic/ thread?
Post by: Wellwisher on June 24, 2015, 03:36:52 PM
I am an advocate of freedom of speech Kindred. I wish to encourage discussions and I want people to share links which basically cultivates a positive environment for members. Banning them for sharing with a geninue interest is too extreme of a measure.

For the moment at least, Suki's initial code is perfect, I might later modify it to add additional topics. If I do, I will add the updated code here. Thank you for all your help Devs!  :)