Hi all,

I'm trying to remove the "email this page" links from the comments (I'd like to have them on nodes only). I've looked at "emailpage.module" and here is a function that adds links. I am not profecient in PHP enugh to do it myself. Could someone modify this function so it doesn't output "email this page" on every comment link?

Thanks!!!

Mel

function emailpage_link($type, $node=0, $main=0) {
  $links=array();


  // This var is set in the settings section under the admin/modules/emailpage section
  // It shows 'email this $nodetype' or 'email this page'
  $e_l_t=variable_get('emailpage_link_type', 0);
  if($e_l_t) {
    if($type == "comment") {
      $e_l_t = "comment";
      $links[] = l(t("email this ".$e_l_t), "emailpage&nid=$node->nid&cid=$node->cid", array("title" => t("Email this page to a friend"), 'class' => 'email-page' ), NULL);
      return $links;
    }
    $e_l_t=$node->type;
  } else $e_l_t="page";

    
  if($main) {  // not on an index page
    if(variable_get('emailpage_show_on_main', 0)) {  
      $links[] = l(t("email this ".$e_l_t), "emailpage&nid=$node->nid", array("title" => t("Email this page to a friend"), 'class' => 'email-page' ), NULL);
      return $links;
	  }
  } else { 
	// not on a main page
    $links[] = l(t("email this ".$e_l_t), "emailpage&nid=$node->nid", array("title" => t("Email this page to a friend"), 'class' => 'email-page'), NULL);
     return $links;
	}

Comments

Mateo’s picture

function emailpage_link($type, $node=0, $main=0) {
  $links=array();
  // This var is set in the settings section under the admin/modules/emailpage section
  // It shows 'email this $nodetype' or 'email this page'
  $e_l_t=variable_get('emailpage_link_type', 0);
  if($e_l_t) {
    if($type == "comment") {
//removed
    }
    $e_l_t=$node->type;
  } else $e_l_t="page";
  if($main) { // not on an index page
    if(variable_get('emailpage_show_on_main', 0)) {
      $links[] = l(t("email this ".$e_l_t), "emailpage&nid=$node->nid", array("title" => t("Email this page to a friend"), 'class' => 'email-page' ), NULL);
      return $links;
}
  } else {
// not on a main page
    $links[] = l(t("email this ".$e_l_t), "emailpage&nid=$node->nid", array("title" => t("Email this page to a friend"), 'class' => 'email-page'), NULL);
     return $links;
}

I started coding something else, but it looks like either you or someone else threw in the "$e_l_t=$node->type;" line which doesn't seem to jive with how the rest of the code is working.

instead I just decided to remove the call to the "links" array when the $type is a "comment." The logic thinks like this: If the $type is a comment, nothing happens. If it's not a comment (ie, a node) it will add the link.

My code isn't tested, but it should work.

melissa-b’s picture

Hi,

This "email this page" link is indestructible :) It's still there on all comments! I had to add this if-statement (to the last block of code) to finally get rid of them on all comments:

	if($type != "comment") {
    $links[] = l(t("email this ".$e_l_t), "emailpage&nid=$node->nid", array("title" => t("Email this page to a friend"), 'class' => 'email-page'), NULL);
     return $links; 
	}

Thanks all!!!

Mel

DriesK’s picture

When you post PHP code, you can also post it between <?php ?> tags. If you do so, your code will get colored, so that it will be much easier to read. If you just use <code> tags, it is quite difficult to quickly review your code.