如何在另一页上显示节点/添加/类型表? [英] How to display node/add/sometype form on another page?

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

问题描述

整个问题如下:

我们说我们有项目,项目可以有出价,项目可以有问题,问题可以有答案。

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天全站免登陆