天天看點

drupal 架構

XX 代表自己的項目名 每次新的項目都要改一遍名稱   

XX_menu   $arr = array ('do' =>'接口');     

sites/ sites.php

$sites["192.168.33.10.軟鍊(和項目名相同的軟鍊)"] = "項目名稱";         // 配置

浏覽器輸入  192.168.33.10/軟鍊       192.168.33.10 可在host下配置成自己的位址   這個ip是 vagrant配置下的設定的

// page callback  是回調函數

// 接口的菜單

foreach ( $arr as $key => $value ) {

    $items[$key] = array(

        'title'            => $value,

        'page callback'    => "XX_{$key}",

        //'page arguments'   => array( $key ),

        'page arguments'   => array( 1, 2, 3 ),

        'access callback'  => true,

        'access arguments' => array( 'access content' ), // administer users 管理者權限

        'menu_name'        => 'project-menu', // 主菜單:main-menu

        'weight'           => 10,

        'file'             => 'XX.pages.inc',

    );

}

//   在背景 内容區塊中添加

foreach ( XX_init_menu() as $machine_name => $node_type  ) {

  $items[str_replace('_', '-', $machine_name).'/list'] = array(

    'title'            => t($node_type->name),

    'page callback'    => "sw2017_node_list",

    //'page arguments'   => array( $key ),

    'page arguments'   => array( $node_type->type ),

    'access callback'  => true,

    'access arguments' => array( 'access content' ), // administer users 管理者權限

    'menu_name'        => 'project-menu', // 主菜單:main-menu

    'weight'           => 10,

    'file'             => 'XX.pages.inc',

  );

}

//  資料清單

$items['admin/tb/custom_表名'] = array(

  'title'            => '心說答題記錄',

  'weight'           => 1,

  'type'             => MENU_LOCAL_TASK,

  'context'          => MENU_CONTEXT_INLINE, // 隻在菜單裡顯示

  'access arguments' => array( 'administer site configuration' ),

);

// 資料庫配置

$databases['default']['default'] = array(

    'driver' => 'mysql',

    'database' => 'biz_表名',

    'username' => 'root',

    'password' => 'vagrant',

    'host' => 'localhost',

    'port' => 3306,

    'prefix' => '',

    'collation' => 'utf8_general_ci',

);