Jump to content

How to add no follow attribute in php ?


Themb

Recommended Posts

Aim: I have a site that displays publishes articles and want to add a no follow around the string that pulls the author's ressource info and displays it in html. I want to put a no follow attribute around that whole area to "neutralize" the links.

 

Geeks and freaks I need your help Please!!!! if there is anything that needs to be explained do it laymans english lolol thanks in advance.

 

Here is the code I have colored the part I want to apply the no follow to:

 

<span class="fonttitle"> Related Articles :
                                 </span></td>
                             </tr>
                             <tr>
                               <td>
                                 <ul style="list-style-image: url(images/a3.gif);">
<? 
		  	$res_rel = $obj_db->select("SELECT intRelatedArticles  FROM `tblsettings`");
			$relarticle = $res_rel[0]['intRelatedArticles'];


		  	$sql2 = "SELECT * FROM `tblarticles` where intCategory = '$categid' AND  intStatus = 1 ORDER BY `ttSubmitDate` DESC LIMIT 0 , $relarticle  ";
			$result2= $obj_db->select($sql2);

                                   ?>
<? 
		  		if($result2)
				{
				$i=0;

				foreach($result2 as $row)
				{$i=$i+1;

				$the_title = stripString($row['varArticleTitle']);
$bad = array("?", "!", " ", ":", ";", "'");
$good = array("", "", "-", "", "", "");
                                   ?>
                                   <li>
                                   <a href="articledetail.php?artid=<? echo $row['intId'];?>&catid=<? echo $row['intCategory'];?>&title=
                                     <?php echo str_replace(" ","-",$the_title) ?>
                                     ">
                                     <? echo stripString($row['varArticleTitle']);?></a>
<?	} 
			}
			else
			{
                                   ?>
                                   <li> There is no related Articles.
                                   <br> Thank you.
<?
			}

			include_once "markdown.php";
       $my_html = Markdown($arttext);
                                   ?>
                                 </ul>
                                 <form name="myform" action="">
                                   <p>
                                   </p></td>
                             </tr>
                             <tr>
                               <td>
                                 <p>
                                   <b>HTML Ready Article. Click on the "Copy" button to copy into your clipboard.</b>
                                   <br>
                                   <br>
<textarea  cols="60" rows="30" title="Article Friendly Ezine Ready Article" name="txtMessage">
<?php echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>" ?>;
<html><head><title><?php echo $title; ?> | <?php echo $artname ?></title></head><body><h3><?php echo $artname ?></h3><br><br> By: <?php echo $authorname ?><br><br><?php echo $my_html ?><br><br> [color=red]<b>Author Resource:-></b>  <?php echo str_replace("\n","<br>",$html) ?><br><br>[/color]<?php echo "<b>Article From</b> <a href='".$site_URL."'>".$title."</a>"; ?><br></body></html></textarea>
                                 </p><br />
                                 <center>
                                   <input type="button" onclick='return copy_clip(document.myform.txtMessage.value)' value="Copy!">
                                   <br>
                                   <br>
                                   <font color="gray" size="1">
                                     Firefox users please select/copy/paste as usual
                                   </font>
                                 </center></td>
                             </tr>
                       </table>
                       </form></td>
                   </tr>
                 </table></td>
               <td width="161" valign="top" class="box">
                 <?php require_once(INC."extra_rlinks.inc.php"); ?></td>
             </tr>
         </table>
         <div align="center" class="head_bold">
           <?php require_once(INC."bottom.inc.php"); ?>
         </div>
 </body>

Link to comment
https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/
Share on other sites

Guys thanks for the quick answer!!

Yeah putting a no Follow on the whole page is not what I want to do.... I just want to do it in the article author resource box.

Daniel0: What is that code you pasted in your answer?? (excuse my ignorance)

Huummmm there must be a way.... Any suggestions??? is not possible to write code that will add the attribute anywhere it finds the hyperlink bewtween a delimited area??? I mean I have seen it the comment sections in blogs...  :'(

Daniel!!! God Bless you!!! thanks.... I looked everywhere but no clear answer.... I found this discussion not sure if at all relevant:

http://guff.szub.net/2005/01/27/add-link-attribute/

 

Could you guide me on where to stick that line of code? I am a complete php idiot! but I have made it my goal to learn it  :-\

If you need SEO help please let me know... that is my gig!! Cheers and awaiting the response.... I will be thrilled when I see it work!!

FYI: The authors' articles needs to be approved according to guidelines... trust has to be earned lol....

You could take this part of your code:

<?php echo str_replace("\n","<br>",$html) ?>

and change it to

<?php echo str_replace("\n","<br>", preg_replace('#<a(.*)>(.*)</a>#iU', '<a$1 rel="nofollow">$2</a>', $html)) ?>

 

It should work, but I haven't tested it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.