drush가있는 컨텐츠 유형 목록을 얻으려면 어떻게해야합니까? : $ drush @d6 @sites genc

drush로 기존 컨텐츠 유형 목록을 얻으려면 어떻게해야합니까? 이렇게하면 목록을 빠르게 만들 수 있습니다.

나는 시도했다 :

$ drush @d6 @sites genc --types

그러나이 devel_generates기능을 사용 하려면 모듈이 필요합니다 .

genc 명령을 실행하려면 devel_generate 모듈을 활성화해야합니다.



답변

라는 이름의 drush 명령을 만들 수 있습니다 content-type-list. 라는 모듈을 만들고 drush_content_types안쪽 drush_content_types.drush.inc이 코드를 넣어 파일 :

<?php
/**
 * @file
 * Drush commands related to Content Types.
 */

/**
* Implements hook_drush_command().
*/
function drush_content_types_drush_command() {
  $items['content-type-list'] = array(
    'description' => dt("Show a list of available content types."),
    'aliases' => array('ctl'),
  );
  return $items;
}

/**
 * Callback for the content-type-list command.
 */
function drush_drush_content_types_content_type_list() {
  $content_types = array_keys(node_type_get_types());
  sort($content_types);

  drush_print(dt("Machine name"));
  drush_print(implode("\r\n", $content_types));
}

모듈을 설치하고 실행 drush cc drush하여 drush 캐시를 지우고 다음과 같은 명령을 사용하십시오.

drush ctl

또는

drush content-type-list

명령에 다른 별명을 추가하려면 다음과 같이 별명 배열에 요소를 추가하십시오.

'aliases' => array('ctl', 'all-content-types', 'act'),

이 명령을 사용할 수 있습니다 :

drush act
drush all-content-types
drush ctl
drush content-type-list

항상 출력은 다음과 같습니다

Machine name:
content 1
content 2
content...
content n


답변

이름 목록 :

drush sqlq "SELECT name FROM node_type;"

기계 이름 목록 :

drush sqlq "SELECT type FROM node_type;"

이것은 D6과 D7에서 작동합니다.

명령 출력의 첫 번째 줄은 각각 name또는 type입니다. |tail -n +2첫 번째 줄을 삭제하려면 파이프를 사용하십시오.


답변

다음 명령을 시도하십시오.

드루팔 7 & 8

drush ev "print_r(array_keys(node_type_get_types()));"

드루팔 5 & 6

drush ev "print_r(array_keys(node_get_types()));"


답변

Drupal에서 수행하는 방법을 알고 있다면 다음을 사용해야합니다 drush eval.

드루팔 6 :

drush eval '$types = node_get_types(); foreach($types as $type => $object) { print $type . "\n"; }'

드루팔 7 :

drush eval '$types = node_type_get_types(); foreach($types as $type => $object) { print $type . "\n"; }'

사용 하는 다른 유용한 예 는이 drush 명령 목록을 참조하십시오 eval.


답변