Drupal 7 모듈의 골격 구조는 무엇입니까?


14

Drupal 7 모듈을 구축하는 데 필요한 파일은 무엇입니까? 기본 .info 파일을 구성하기위한 요구 사항은 무엇입니까? 이 질문의 본질은 기본 Drupal 7 모듈을 처음부터 구축하기위한 골격을 제공하는 것입니다.


당신이 질문을 downvote 경우 해결 될 수 있도록 이유를 게시하십시오.
Lester Peabody

답변:


13

필요한 최소 파일 :

일반적으로 모듈에 필요한 최소 파일은 다음과 같습니다.

sites / all / modules / {모듈 이름}

  • {your module}.info
  • {your module}.module

또는 예제 모듈을 사용하십시오.

drupal.org 의 예제 모듈 은 사용자 정의 / contrib 모듈을 개발하기위한 기본 모듈을 제공합니다. 이것을 사용하여 모듈을 복사하고 만들 수 있습니다.

프로젝트 페이지를 확인 하십시오 .

이 프로젝트는 광범위한 Drupal 핵심 기능에 대해 잘 문서화 된 고품질 API 예제를 제공하는 것을 목표로합니다.

(다른 비 핵심 사례에 관심이 있습니까?)

개발자는 예제를 실험하여 특정 API를 빠르게 사용하는 방법을 배우고 자신의 용도에 맞게 조정할 수 있습니다.

자식 저장소에 연결 하십시오 : http://drupalcode.org/project/examples.git/tree/refs/heads/7.x-1.x

예제 모듈의 코드 :

또한 예제 모듈에서 얻을 수있는 코드를 붙여 넣었습니다.

example.info 파일 :

name = Examples For Developers
description = A variety of example code for you to learn from and hack upon.
package = Example modules
core = 7.x

example.module 파일 :

<?php

/**
 * @file
 * This file serves as a stub file for the many Examples modules in the
 * @link http://drupal.org/project/examples Examples for Developers Project @endlink
 * which you can download and experiment with.
 *
 * One might say that examples.module is an example of documentation. However,
 * note that the example submodules define many doxygen groups, which may or
 * may not be a good strategy for other modules.
 */

/**
 * @defgroup examples Examples
 * @{
 * Well-documented API examples for a broad range of Drupal 7 core functionality.
 *
 * Developers can learn how to use a particular API quickly by experimenting
 * with the examples, and adapt them for their own use.
 *
 * Download the Examples for Developers Project (and participate with
 * submissions, bug reports, patches, and documentation) at
 * http://drupal.org/project/examples
 */

/**
 * Implements hook_help().
 */
function examples_help($path, $arg) {
  // re: http://drupal.org/node/767204
  // 5. We need a master group (Examples) that will be in a main
  // examples.module.
  // The examples.module should be mostly doxy comments that point to the other
  // examples.  It will also have a hook_help() explaining its purpose and how
  // to access the other examples.
}

/**
 * @} End of 'defgroup examples'.
 */

8

1) 모듈 이름을 결정하십시오 (예 : mymodule).

2) 모듈 이름으로 sites / all / modules 내에 폴더를 만듭니다.

3) 폴더 안에 여는 php 태그 ( <?php)가 있는 mymodule.module 파일을 만듭니다 . 닫는 태그 ( ?>)는 생략해야합니다.

4) 다음 3 줄을 사용하여 mymodule.info 파일 (모듈 폴더 안에)을 만듭니다.

 name = Mymodule
 description = Description for the module
 core = 7.x

이것으로 GUI를 통해 활성화 할 수있는 Drupal 7 모듈이 이미 있습니다 (mymodule.module 파일에 함수 / 코드를 추가하지 않은 한 아무것도하지 않습니다). 여기에 사용 된 모든 mymodule 인스턴스는 실제 모듈 이름으로 바꿔야하며 '모듈 설명'은 적절한 설명이어야합니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.