Themb Posted April 25, 2008 Share Posted April 25, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/ Share on other sites More sharing options...
Daniel0 Posted April 26, 2008 Share Posted April 26, 2008 rel='nofollow' only works on links... Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/#findComment-527600 Share on other sites More sharing options...
Xurion Posted April 26, 2008 Share Posted April 26, 2008 You could try the meta: <meta name="ROBOTS" content="NOINDEX, NOFOLLOW"> Not sure if ths is what you want through. Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/#findComment-527612 Share on other sites More sharing options...
Themb Posted April 26, 2008 Author Share Posted April 26, 2008 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... :'( Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/#findComment-527629 Share on other sites More sharing options...
Daniel0 Posted April 26, 2008 Share Posted April 26, 2008 How does the author type it? Using html or bbcodes? Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/#findComment-527630 Share on other sites More sharing options...
Themb Posted April 26, 2008 Author Share Posted April 26, 2008 The author enters it by inserting html.... Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/#findComment-527631 Share on other sites More sharing options...
Daniel0 Posted April 26, 2008 Share Posted April 26, 2008 Well, you could use a regular expression: $text = preg_replace('#<a(.*)>(.*)</a>#iU', '<a$1 rel="nofollow">$2</a>', $text); Unless you trust your authors a lot you're better off using bbcodes though. Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/#findComment-527634 Share on other sites More sharing options...
Themb Posted April 26, 2008 Author Share Posted April 26, 2008 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.... Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/#findComment-527637 Share on other sites More sharing options...
Daniel0 Posted April 26, 2008 Share Posted April 26, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/#findComment-527640 Share on other sites More sharing options...
Themb Posted April 26, 2008 Author Share Posted April 26, 2008 Thanks Man! I will give you an update After I test it... I am sooooo grateful!! Quote Link to comment https://forums.phpfreaks.com/topic/102838-how-to-add-no-follow-attribute-in-php/#findComment-527643 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.