【问题标题】:Drupal problem, how to create a fast content module?Drupal问题,如何创建快速内容模块?
【发布时间】:2009-01-24 20:00:42
【问题描述】:

您好,我需要在 drupal 中创建一个模块来显示一些数据,而不是一个 drupal 开发人员,并且在阅读了几个教程之后,我似乎无法显示任何内容。

我有下一个代码:

<?php
function helloworld_perm() {
  return array('access helloworld content');
} 

function helloworld_listado(){
 return "yea";
}

function helloworld_menu(){
    $items = array();
    $items["listado"] = array(
        'title' => t('Listado de empresas'),
        'callback' => 'helloworld_listado',
        'access' => array('access helloworld content'),
        'type' => MENU_NORMAL_ITEM 
      );
    return $items;
}

当我输入 /listado 时,我得到一个拒绝访问 您无权访问此页面。

知道我做错了什么吗? 如果我转到 admin->module->permissions,我已经检查了所有角色访问 helloold 内容的权限。

泰!

【问题讨论】:

    标签: drupal


    【解决方案1】:

    helloworld_menu() 中菜单数组的结构方式来看,我假设这是 Drupal 6。如果是这样,您需要将“访问”重命名为“访问参数”。见http://api.drupal.org/api/function/hook_menu/6

    Drupal API 文档还包含一个注释较多的 page_example.module,它基本上完成了您在此处所做的工作,您可能想查看:http://api.drupal.org/api/file/developer/examples/page_example.module/6/source

    希望有帮助!

    哦。并且不要忘记之后从管理>>站点配置>>性能上的“清除缓存”按钮清除缓存。

    【讨论】:

      【解决方案2】:
       => t('Listado de empresas'),
          'page callback'    => 'helloworld_listado',
          'access arguments' => array('access helloworld content'),
          'type'             => MENU_NORMAL_ITEM,
        );
      return $items;
      }
      

      请注意,MENU_NORMAL_ITEMtype 的默认值,您无需指定。

      另外,正如我们尊敬的网络小妞刚刚所说的那样

      【讨论】:

        【解决方案3】:

        您似乎在为 hook_menu 使用 Drupal 5(数组内容)和 Drupal 6(没有 $may_cache,$items 由路径索引)语法的混合。

        如果您使用的是 Drupal 6,则应如下所示:

        <?php
        function helloworld_perm() {
          return array('access helloworld content');
        } 
        
        function helloworld_listado(){
         return "yea";
        }
        
        function helloworld_menu(){
            $items = array();
            $items["listado"] = array(
                'title'            => t('Listado de empresas'),
                'page callback'    => 'helloworld_listado',
                'access arguments' => array('access helloworld content'),
                'type'             => MENU_NORMAL_ITEM,
              );
            return $items;
        }
        ?>
        

        请注意,MENU_NORMAL_ITEM 是 'type' 的默认值,您无需指定。

        另外,正如我们尊贵的网妞刚才所说,您可以在她指向的页面上找到详细的解释。

        【讨论】:

          【解决方案4】:

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2015-10-13
            • 2015-12-04
            • 2011-07-08
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多