【问题标题】:display 'add content' form in tpl file在 tpl 文件中显示“添加内容”表单
【发布时间】:2012-10-05 17:52:36
【问题描述】:

我是 Drupal 的新手。 我想在其中加载一个带有“添加内容”表单(在内容类型“故事”下添加故事的表单)的滑块。 我不知道如何在滑块内创建它。

我的主题文件夹中没有 template.php。 是否可以在 tpl 文件中调用表单?

【问题讨论】:

    标签: forms drupal-7 content-type


    【解决方案1】:

    您可以使用drupal_get_form 函数为您的内容类型加载节点表单。尽管理想情况下您不希望在 .tpl 文件中执行此操作,而是在创建块的自定义模块中执行此操作,其中包含该表单。

    .tpl 示例

    <?php
    
        global $user;
        module_load_include('inc','node','node.pages');
        $node_form = drupal_get_form('story_node_form',array('uid'=>$user->uid,'type'=>'story'));
        echo render($node_form);
    

    【讨论】:

      猜你喜欢
      • 2021-05-15
      • 1970-01-01
      • 2021-12-08
      • 1970-01-01
      • 2022-11-01
      • 2015-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多