I need to re-create the links in a customfield because publishing is dependent on the count of another related type of content. In other words, the user cannot publish a project until they have at least 2 project actions. The customfield is working to display the link but I don't know how to re-create the 'code' the module creates that comes after node/nid/publish/ and before the ? in the link. Can someone tell me how to get the missing hash number or whatever it is? Is there a function or something I can use?

Here's my customfield code:


$combined = NULL;
$nid = $data->nid;

$project_status = db_result(db_query("SELECT status FROM {node} WHERE nid = %d", $nid));

$actions_count = db_result(db_query("SELECT COUNT(*) FROM  {content_type_project_action} WHERE field_project_action_related_to_nid = %d", $nid));


If ($project_status == '1' AND $actions_count >= 2) {

  $combined = '<a  href="/node/' . $nid . '/unpublish/?destination=' . $_GET['q'] .'">Unpublish</a>';
  print $combined;
}
If ($project_status == '1' AND $actions_count < 2 ) {

  $combined = '';
  print $combined;
}
If ($project_status == '0' AND $actions_count >= 2) {

  $combined = '<a  href="/node/' . $nid . '/publish/?destination=' . $_GET['q'] .'">Publish</a>';
  print $combined;
}

Thank you!

Comments

simon georges’s picture

Status: Active » Fixed

The function to use should be drupal_get_token().

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.