我想制作一个允许用户为我的内容类型添加帖子的表单。表单将包含我在内容类型中创建的所有字段。一旦用户提交了from,那么条目将自动添加内容类型。
答案 0 :(得分:1)
您可以在表单提交功能
中添加创建新节点function custom_page_submit($form, &$form_state) {
global $user;
//Create new object and fill the fields;
$node = new stdClass();
$node->title = "SOME TITLE";
$node->type = "YOUR_NODE_TYPE";
node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().
$node->language = LANGUAGE_NONE; // Or e.g. 'en' if locale is enabled
$node->uid = $user->uid;
$node->status = 1; //(1 or 0): published or not
$node->promote = 0; //(1 or 0): promoted to front page
$node->comment = 1; // 0 = comments disabled, 1 = read only, 2 = read/write
$node = node_submit($node); // Prepare node for saving
node_save($node);
// Display success message
drupal_set_message("Node was saved!");
// And you can specify where user shoul be redirected
$form_state['redirect'] = 'SOME WHERE'; // 'front' - if redirect to front page
}
答案 1 :(得分:0)
使用公共节点创建系统,并强制它使用前端主题。