I want to have a selectable field for the views module called "close" that executes a function like this: function job_close() { $job = arg(2); $sid = 15; // Should be configurable. workflow_execute_transition($job, $sid); drupal_goto('job/open'); } I've got it to work using the code below, but its not right. I shouldn't have to use a valid field in the 'fields' section. This also means that you can't have multiple versions, ie one to "approve", one to "close". Anybody got any suggestions on a better way? TIA function job_views_tables() { $tables['job'] = array( 'name' => 'job', 'join' => array( 'left' => array( 'table' => 'node', 'field' => 'nid' ), 'right' => array( 'field' => 'nid' ) ), 'fields' => array( 'job_id' => array( 'name' => t('job: Job Id'), 'sortable' => TRUE, ), 'cid' => array( 'name' => t('job: Customer Id'), 'sortable' => TRUE, ), 'nid' => array( 'name' => t('job: Close link'), 'handler' => 'views_handler_field_job_close', ), ), 'sorts' => array( 'job_id' => array('name' => t('Job Id')), 'cid' => array('name' => t('Customer Id')), ), ); return $tables; } function views_handler_field_job_close($op, &$query, $argtype, $arg = '') { switch ($op) { default: return l('close', "job/close/$arg->nid"); } }
Simon Lindsay wrote:
I want to have a selectable field for the views module called "close" that executes a function like this:
function job_close() { $job = arg(2); $sid = 15; // Should be configurable. workflow_execute_transition($job, $sid); drupal_goto('job/open'); }
I've got it to work using the code below, but its not right. I shouldn't have to use a valid field in the 'fields' section. This also means that you can't have multiple versions, ie one to "approve", one to "close".
Anybody got any suggestions on a better way?
You don't have to. You can do: 'fields' => array( 'arbitrary_internal_name' => array( 'name' => t("arbitrary_internal_name"), 'notafield' => TRUE, // The below isn't even necessary if there is simply no field 'field' => 'real_field' (OR) => array('real_field1', 'real_field2') ), ), Is this what you want?
God bless you, this is exactly what I needed to do for VotingAPI, too. --Jeff
-----Original Message----- From: Earl Miles [mailto:merlin@logrus.com] Sent: Friday, February 17, 2006 9:24 AM To: development@drupal.org Subject: Re: [development] Views question
You don't have to.
You can do:
'fields' => array( 'arbitrary_internal_name' => array( 'name' => t("arbitrary_internal_name"), 'notafield' => TRUE, // The below isn't even necessary if there is simply no field 'field' => 'real_field' (OR) => array('real_field1', 'real_field2') ), ),
Is this what you want?
Earl Miles wrote:
You don't have to.
You can do:
'fields' => array( 'arbitrary_internal_name' => array( 'name' => t("arbitrary_internal_name"), 'notafield' => TRUE, // The below isn't even necessary if there is simply no field 'field' => 'real_field' (OR) => array('real_field1', 'real_field2') ), ),
Is this what you want?
Yes, exactly. Excellent! Thankyou Earl!
participants (3)
-
Earl Miles -
Jeff Eaton -
Simon Lindsay