整个问题如下:
让我们说我们有项目,项目可以有投标,项目可以有问题,问题可以有答案.
显示项目时,还应显示与此项目关联的所有内容.此外,根据角色,应显示某些表格以进行投标,提问和重播答案.
怎么做到这一点?我应该为每种类型分别设置节点类型吗?或者我应该将问题和答案等一些子类型视为评论?我应该使用一些众所周知的模块吗?
我正在使用Drupal 7,我试图编写一个自定义模块,但我没有让它正常工作.
Mar*_*lie 35
module_load_include('inc', 'node', 'node.pages');
$form = node_add('nodetype');
$output = drupal_render($form);
Run Code Online (Sandbox Code Playgroud)
如果您的节点表单具有文件上载小部件,则应将以下行添加到菜单数组中:
'file path' => drupal_get_path('module', 'node'),
'file' => 'node.pages.inc',
Run Code Online (Sandbox Code Playgroud)
dob*_*man 20
要获取节点编辑表单,您需要包含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);
?>
Run Code Online (Sandbox Code Playgroud)
小智 5
// Drupal 7
// Embed node creation form on a custom page inside module.
module_load_include('inc', 'node', 'node.pages');
$form = node_add('node_machine_name');
return drupal_render($form);
Run Code Online (Sandbox Code Playgroud)