如何在另一个页面上显示节点/添加/某种形式? [英] How to display node/add/sometype form on another page?

查看:14
本文介绍了如何在另一个页面上显示节点/添加/某种形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

整个问题如下:

假设我们有项目,项目可以有投标,项目可以有问题,问题可以有答案.

Lets say we have Items, Items can have Bids, Items can have Questions and Question can have Answer.

当一个项目被显示时,与这个项目相关的所有内容也应该被显示.此外,根据角色的不同,还应显示某些用于投标、提问和重播答案的表格.

When an Item is displayed, all content associated with this Item should also be displayed. Additionally depending on roles, certain forms to make Bids, ask Questions and replay Answers should be display.

如何做到这一点?我应该为每种类型设置单独的节点类型吗?或者我应该将问题和答案等一些子类型视为评论?我应该为此使用一些知名模块吗?

How to achieve this? Should I have separate node type for each type? Or should I treat some subtypes like Questions and Answers as comments? Should I use some well-known modules for this?

我正在使用 Drupal 7,我尝试编写一个自定义模块,但我没有让它正常工作.

I am using Drupal 7 and I tried to write a custom module but I didn't get it working properly.

推荐答案

要获取节点编辑表单,需要包含 node.pages.inc.

To get a node edit form, you need to include node.pages.inc.

<?php
  // required for Drupal 6
  module_load_include('inc', 'node', 'node.pages'); 
  // which nodeform you want
  $node_type = 'YOURNODETYPE';
  $form_id = $node_type . '_node_form';
  // maybe add current users info
  global $user;
  // create a blank node
  $node = array(
    'uid' => $user->uid,
    'name' => (isset($user->name) ? $user->name : ''),
    'type' => $node_type,
  );
  // Invoke hook_nodapi and hook_node
  node_object_prepare($node);
  // Or you can also use an exiting node, for example
  // $node = node_load(123);
  // and the display the form:
  $output = drupal_get_form($form_id, $node);
?>

这篇关于如何在另一个页面上显示节点/添加/某种形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆