【问题标题】:How to create html page in dupal 7如何在 drupal 7 中创建 html 页面
【发布时间】:2014-10-13 18:24:27
【问题描述】:

我正在尝试使用 Drupal 7 开发一个 Web 应用程序。我想创建自己的 html 页面并将它们包含在我的 drupal 中。我已经看到,在 drupal 示例模块中给出的这个示例中,hook_menu API 是可能的(见下文)。当你想创建一个页面“Hello World Technology”时,这种方法很酷,但是如果我想包含更复杂的 html 页面怎么办?我是否必须将我的 500 行 html 代码放在关联数组 '#markup' 中并转义所有 " 或 ' 字符?我永远不会以这种速度完成我的网络应用程序...

你们能帮我或建议我吗?

非常感谢

function page_example_menu() {

  // This is the minimum information you can provide for a menu item. This menu
  // item will be created in the default menu, usually Navigation.
  $items['examples/page_example'] = array(
    'title' => 'Page Example',
    'page callback' => 'page_example_description',
    'access callback' => TRUE,
    'expanded' => TRUE,
  );

  $items['examples/page_example/simple'] = array(
    'title' => 'Simple - no arguments',
    'page callback' => 'page_example_simple',
    'access arguments' => array('access simple page'),
  );

  return $items;
}

function page_example_description() {
  return array(
    '#markup' =>
    t('<p>The page_example provides two pages, "simple" and "arguments".</p><p>The <a href="@simple_link">simple page</a> just returns a renderable array for display.</p><p>The <a href="@arguments_link">arguments page</a> takes two arguments and displays them, as in @arguments_link</p>',
      array(
        '@simple_link' => url('examples/page_example/simple', array('absolute' => TRUE)),
        '@arguments_link' => url('examples/page_example/arguments/23/56', array('absolute' => TRUE)),
      )
    ),
  );
}

function page_example_simple() {
  return array('#markup' => '<p>' . t('Simple page: The quick brown fox jumps over the lazy dog.') . '</p>');
}

【问题讨论】:

    标签: php html drupal drupal-7


    【解决方案1】:

    考虑到 Drupal 是一个内容管理系统,而您想要实现的是 Drupal 所做工作的核心。

    创建您自己的 HTML 页面:

    导航到 /node/add 选择一个普通页面(您甚至可以稍后创建自己的内容类型)。 将所有 HTML 放入正文中,您可以选择输入过滤器,如果需要,可以转到源代码模式,您可能想查看包括 CKEditor 或某种所见即所得的方法,这在 Drupal 中很常见。

    您可以在同一屏幕中设置 URL。

    无需为基本的 HTML 页面创建菜单挂钩并在代码中添加标记,这就是 CMS 的用途!

    【讨论】:

    • 您好 klidifia,感谢您的更新。其实我需要做的是一个带有php的webapp,有些部分是纯静态html,有些部分是动态的,我可以用你给我的方法吗?提前谢谢你。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-25
    相关资源
    最近更新 更多