问题描述
整个问题如下:
假设我们有项目,项目可以有投标,项目可以有问题,问题可以有答案.
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);
?>
这篇关于如何在另一个页面上显示节点/添加/某种类型的表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!