如何在drupal中查询cck字段?

如何在drupal中查询cck字段?,drupal,cck,Drupal,Cck,我使用节点引用+节点引用url节点链接了两种内容类型(job_post和application)。当我单击job_post节点中的链接时,将创建一个新的应用程序节点,以便候选人可以填写他们的职务申请。我的目标是自动将cck电子邮件字段的内容从引用的job_post节点复制到应用程序节点中的cck电子邮件字段 为此,我创建了以下模块: // Implementation of hook_perm() function mymodule_perm() { return array('c

我使用节点引用+节点引用url节点链接了两种内容类型(job_post和application)。当我单击job_post节点中的链接时,将创建一个新的应用程序节点,以便候选人可以填写他们的职务申请。我的目标是自动将cck电子邮件字段的内容从引用的job_post节点复制到应用程序节点中的cck电子邮件字段

为此,我创建了以下模块:

// Implementation of hook_perm()
      function mymodule_perm() {
 return array('copy cck field');
    }

 // Implementation of hook_node_api    

function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4  = NULL){
 switch ($op) {

//if the node is inserted in the database

      case 'prepare':
        //if node is a job application
   if($node->type == 'application') {

//get nid from referenced node (using url information    
    $item_nid = arg(3);

//load and build node content
    $item_node = node_load($item_nid);
    $item_node = node_build_content($item_node);

//retrieve data from cck email field in referenced job post node    
                            $item_email = $item_node->field_job_email[0]['view'];

//display result in  website to check if value is correctly loaded
                            dsm($item_email);
不幸的是,当我得到这段代码时,dsm返回一个空值

当我对代码进行以下更改时:

//retrieve data from cck email field in referenced job post node    
                            $item_email = $item_node->field_job_email;

//display result in  website to check if value is correctly loaded
                            dsm($item_email);
我在克鲁莫得到了以下结果:

... (Array, 1 element)
     0 (Array, 2 elements)
          email(string, 9 characters) aa@aa.com
          safe (string, 9 characters) aa@aa.com
关于如何加载cck电子邮件地址字段内容的任何建议(aa@aa.com)进入一个新领域


非常感谢你

我可能误解了这里的某些内容,但Krumo似乎告诉您,
$item\u node->field\u job\u email[0]
没有“view”属性


您是否尝试过
$item\u email=$item\u node->field\u job\u email[0]['safe']

这起作用了!非常感谢您的帮助(因为您发现我对PHP和Drupal还是很陌生)。也适用于$item_email=$item_node->field_job_email[0]['email'];“safe”属性的内容是通过PHP和Drupal的清理函数运行的,因此您应该始终使用该函数,以确保安全。