Closed (fixed)
Project:
Publish Content
Version:
6.x-1.4
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Oct 2012 at 16:34 UTC
Updated:
6 Apr 2013 at 11:20 UTC
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
Comment #1
simon georges commentedThe function to use should be
drupal_get_token().