【问题标题】:get data from just created node and pass it to url从刚刚创建的节点获取数据并将其传递给 url
【发布时间】:2012-10-29 13:02:50
【问题描述】:

我需要创建一个将在保存某个内容类型节点后触发的操作,我需要脚本从提交的节点收集 zip 位置数据并将其提交到视图 ulr

这是插入数据的表单。

<fieldset class="location">
  <legend>Location</legend>
  <div id="edit-locations-0-postal-code-wrapper" class="form-item">
    <label for="edit-locations-0-postal-code">
      Postal code:
      <span title="This field is required." class="form-required">*</span>
    </label>
    <input type="text" class="form-text required" value="" size="16"
           id="edit-locations-0-postal-code" name="locations[0][postal_code]" 
           maxlength="16">
  </div>
</fieldset>

这是我要插入数据的网址

www.mysite.com/testview?distance[postal_code]=DATA_GOES_HERE

【问题讨论】:

  • 用户是否被带到了位于 DATA_GOES_HERE URL 的页面,或者这发生在幕后?

标签: drupal-6


【解决方案1】:

你必须选择:

1) 安装模块:Token + Rules

启用模块后,请按照以下一般步骤操作:

  • 创建新规则
  • 事件:保存新内容后
  • 添加条件:节点:内容有类型(选择您希望应用此规则的内容类型)
  • 添加操作:系统:页面重定向
  • 使用令牌替换模式来构建您希望重定向的 URL(您应该可以访问所有节点字段,包括 CCK 字段)

2) 在您的自定义模块中实现hook_nodeapi()

通过实现这个钩子,你可以访问 $node 对象,传递给钩子的第二个参数是$op,它告诉你正在执行什么操作。在您的情况下,您可能对以下内容感兴趣:

“insert”:节点刚刚被创建(插入到数据库中)。

你的问题和这个很相似,看看:Redirect a user after the node has been saved

【讨论】:

    猜你喜欢
    • 2020-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-04
    • 1970-01-01
    相关资源
    最近更新 更多