【问题标题】:combine two node forms .. is that possible?结合两种节点形式..这可能吗?
【发布时间】:2011-04-10 16:33:46
【问题描述】:

我正在使用 drupal 6,并且我有一个内容类型 1 的 node_form,我想更改第一个内容类型中的其他内容类型节点表单,这可能吗?

【问题讨论】:

    标签: forms drupal-6 cck


    【解决方案1】:

    如果您想将值从第一种形式添加到第二种形式,您可以使用 hook_nodeapi() 来更改第二种内容类型节点。

    function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
      switch($op){
        case 'presave':
          if($node->type == MY_NODE_TYPE){
            // $other_node = node_load($other_nid);
            // or
            // $other_node = new stdClass();
            // $other_node->title = ...
            // ...
            // some code to altering other node
            // $other_node = node_submit($other_node);
            // node_save($other_node);
          }
          break;
      }
    }
    

    【讨论】:

    • 是的,但是表格呢?我如何更改该表单中的字段和标题
    • 你想做什么,更新现有节点或创建其他类型的新节点?
    • 只需将字段从内容类型 1 更改为 formapi 方式中的其他内容类型:$form[contenttypefiled1]=所有值、最小值/最大值、前缀后缀、类和属性等
    • 你能找回其他类型节点的NID吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    • 2014-10-14
    • 2021-12-31
    • 1970-01-01
    相关资源
    最近更新 更多