백엔드 개발 PHP 튜토리얼 Explore block module in Drupal_PHP教程

Explore block module in Drupal_PHP教程

Jul 14, 2016 am 10:07 AM
Block drupal explore module the

block.info is the block module description file and the "package" property tells us that block is Drupal core module and it can be configured by menu "admin/structure/block".

 
block.install is executed when block is installed. The purpose of this file is to create the necessary tables: block, block_custom, block_role
 
Table block is used to store the block information declared by code statements;
Table block_custom is used to store the block information created by administration interface;
Table block_role is used to control the visibility of blocks.
The main logic are defined in the block.module file. Let us go around this file.There are lots of functions in block.module,but they can be categorized into two types: hook function and block module internal-used function.hook function includes block_menu, block_theme, block_theme_initialize, block_themes_enable.
Function block_menu:block configuration, block management, block list by theme
[html]   
  $default_theme = variable_get('theme_default', 'bartik');  
  $items['admin/structure/block'] = array(  
    'title' => 'Blocks',  
    'description' => 'Configure what block content appears in your site\'s sidebars and other regions.',  
    'page callback' => 'block_admin_display',  
    'page arguments' => array($default_theme),  
    'access arguments' => array('administer blocks'),  
    'file' => 'block.admin.inc',  
  );  
  $items['admin/structure/block/manage/%/%'] = array(  
    'title' => 'Configure block',  
    'page callback' => 'drupal_get_form',  
    'page arguments' => array('block_admin_configure', 4, 5),  
    'access arguments' => array('administer blocks'),  
    'file' => 'block.admin.inc',  
  );  
  $items['admin/structure/block/manage/%/%/configure'] = array(  
    'title' => 'Configure block',  
    'type' => MENU_DEFAULT_LOCAL_TASK,  
    'context' => MENU_CONTEXT_INLINE,  
  );  
  $items['admin/structure/block/manage/%/%/delete'] = array(  
    'title' => 'Delete block',  
    'page callback' => 'drupal_get_form',  
    'page arguments' => array('block_custom_block_delete', 4, 5),  
    'access arguments' => array('administer blocks'),  
    'type' => MENU_LOCAL_TASK,  
    'context' => MENU_CONTEXT_NONE,  
    'file' => 'block.admin.inc',  
  );  
  $items['admin/structure/block/add'] = array(  
    'title' => 'Add block',  
    'page callback' => 'drupal_get_form',  
    'page arguments' => array('block_add_block_form'),  
    'access arguments' => array('administer blocks'),  
    'type' => MENU_LOCAL_ACTION,  
    'file' => 'block.admin.inc',  
  );  
  foreach (list_themes() as $key => $theme) {  
    $items['admin/structure/block/list/' . $key] = array(  
      'title' => check_plain($theme->info['name']),  
      'page arguments' => array($key),  
      'type' => $key == $default_theme ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,  
      'weight' => $key == $default_theme ? -10 : 0,  
      'access callback' => '_block_themes_access',  
      'access arguments' => array($theme),  
      'file' => 'block.admin.inc',  
    );  
    if ($key != $default_theme) {  
      $items['admin/structure/block/list/' . $key . '/add'] = array(  
        'title' => 'Add block',  
        'page callback' => 'drupal_get_form',  
        'page arguments' => array('block_add_block_form'),  
        'access arguments' => array('administer blocks'),  
        'type' => MENU_LOCAL_ACTION,  
        'file' => 'block.admin.inc',  
      );  
    }  
    $items['admin/structure/block/demo/' . $key] = array(  
      'title' => check_plain($theme->info['name']),  
      'page callback' => 'block_admin_demo',  
      'page arguments' => array($key),  
      'type' => MENU_CALLBACK,  
      'access callback' => '_block_themes_access',  
      'access arguments' => array($theme),  
      'theme callback' => '_block_custom_theme',  
      'theme arguments' => array($key),  
      'file' => 'block.admin.inc',  
    );  
  }  
  return $items;  
}  
Function block_theme: offers two theme options: block is for front-end and block_admin_display_form is for administration interface
[html]  
function block_theme() {  
  return array(  
    'block' => array(  
      'render element' => 'elements',  
      'template' => 'block',  
    ),  
    'block_admin_display_form' => array(  
      'template' => 'block-admin-display-form',  
      'file' => 'block.admin.inc',  
      'render element' => 'form',  
    ),  
  );  
}  
Function block_theme_initialize: assign the blocks to theme's regions
[php]  
function block_theme_initialize($theme) {  
  // Initialize theme's blocks if none already registered.  
  $has_blocks = (bool) db_query_range('SELECT 1 FROM {block} WHERE theme = :theme', 0, 1, array(':theme' => $theme))->fetchField();  
  if (!$has_blocks) {  
    $default_theme = variable_get('theme_default', 'bartik');  
    // Apply only to new theme's visible regions.  
    $regions = system_region_list($theme, REGIONS_VISIBLE);  
    $result = db_query("SELECT * FROM {block} WHERE theme = :theme", array(':theme' => $default_theme), array('fetch' => PDO::FETCH_ASSOC));  
    foreach ($result as $block) {  
      // If the region isn't supported by the theme, assign the block to the theme's default region.  
      if ($block['status'] && !isset($regions[$block['region']])) {  
        $block['region'] = system_default_region($theme);  
      }  
      $block['theme'] = $theme;  
      unset($block['bid']);  
      drupal_write_record('block', $block);  
    }  
  }  
}  
Function block_themes_enable: iterate the theme list and assign block list to its regions. 
[html]  
function block_themes_enabled($theme_list) {  
  foreach ($theme_list as $theme) {  
    block_theme_initialize($theme);  
  }  
}  
 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477871.htmlTechArticleblock.info is the block module description file and the package property tells us that block is Drupal core module and it can be configured by menu admin/structure/block. block.inst...
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Moondrop, 지연 시간이 짧은 게임 모드를 갖춘 Block 진정한 무선 이어버드 출시 Moondrop, 지연 시간이 짧은 게임 모드를 갖춘 Block 진정한 무선 이어버드 출시 Aug 10, 2024 pm 03:31 PM

Moondrop은 오디오 매니아를 위해 외이에 편안하게 착용할 수 있는 Block 진정한 무선 이어버드를 출시했습니다. 외이도에 걸린 이어버드와 달리 Block은 귀가 막히는 느낌을 유발하지 않으며 귀지를 수집하지 않습니다. 13mm 드라이버가 동봉되어 있습니다.

2개월 만에 휴머노이드 로봇 '워커S' 옷 개기 가능 2개월 만에 휴머노이드 로봇 '워커S' 옷 개기 가능 Apr 03, 2024 am 08:01 AM

기계력 보고서 편집자: 우신(Wu Xin) 국내판 휴머노이드 로봇+대형 모델팀이 옷 접기 등 복잡하고 유연한 재료의 작업 작업을 처음으로 완료했습니다. OpenAI 멀티모달 대형 모델을 접목한 Figure01이 공개되면서 국내 동종업체들의 관련 진전이 주목받고 있다. 바로 어제, 중국의 "1위 휴머노이드 로봇 주식"인 UBTECH는 Baidu Wenxin의 대형 모델과 긴밀하게 통합되어 몇 가지 흥미로운 새로운 기능을 보여주는 휴머노이드 로봇 WalkerS의 첫 번째 데모를 출시했습니다. 이제 Baidu Wenxin의 대형 모델 역량을 활용한 WalkerS의 모습은 이렇습니다. Figure01과 마찬가지로 WalkerS는 움직이지 않고 책상 뒤에 서서 일련의 작업을 완료합니다. 인간의 명령을 따르고 옷을 접을 수 있습니다.

ModuleNotFoundError: Python 모듈을 찾을 수 없음 오류를 해결하는 방법은 무엇입니까? ModuleNotFoundError: Python 모듈을 찾을 수 없음 오류를 해결하는 방법은 무엇입니까? Jun 25, 2023 pm 09:30 PM

Python 개발 과정에서 모듈을 찾을 수 없다는 오류가 자주 발생합니다. 이 오류의 구체적인 표현은 Python이 모듈을 가져올 때 ModuleNotFoundError 또는 ImportError라는 두 가지 오류 중 하나를 보고한다는 것입니다. 이 오류는 매우 짜증나고 프로그램이 제대로 실행되지 않을 수 있으므로 이 기사에서는 이 오류의 원인과 해결 방법을 살펴보겠습니다. Pyth의 ModuleNotFoundError 및 ImportError

Java9 새로운 기능 모듈 모듈식 프로그래밍 방법 Java9 새로운 기능 모듈 모듈식 프로그래밍 방법 May 19, 2023 pm 01:51 PM

Java9 버전에서 Java 언어는 모듈이라는 매우 중요한 개념을 도입했습니다. JavaScript 코드의 모듈식 관리에 익숙하다면 Java 9의 모듈식 관리를 보면 익숙할 것입니다. 1. 자바 모듈이란 무엇입니까? Java의 패키지와 다소 유사하게 모듈은 또 다른 수준의 Java 코드 그룹화를 도입합니다. 이러한 각 그룹(모듈)에는 많은 하위 패키지가 포함되어 있습니다. 모듈의 소스 코드 파일 패키지 루트에 module-info.java 파일을 추가하여 폴더와 해당 하위 폴더를 모듈로 선언합니다. 파일 구문

Drupal 구성을 분석하는 방법 Drupal 구성을 분석하는 방법 May 15, 2023 pm 09:22 PM

Drupal 구성 Drupal은 상당히 복잡한 아키텍처를 갖춘 오픈 소스 PHP 콘텐츠 관리 시스템입니다. 또한 강력한 보안 모델도 갖추고 있습니다. 커뮤니티 개발자들의 기여와 유지 관리 덕분에 Drupal 웹사이트의 보안 구성을 강화하기 위한 자세한 문서와 방법이 많이 있습니다. 웹사이트를 운영하려면 Drupal이 필요하다는 점을 기억하세요. 해커로부터 전체 시스템을 보호하려면 전체 시스템을 다루어야 합니다. 여기에는 몇 가지 일반적인 서버 설정, 웹 서버 구성, PHP 및 데이터베이스가 포함됩니다. 또한 서버의 다른 서비스도 올바르게 구성해야 합니다. 이는 서버 및 웹 사이트 관리자가 전체 시스템의 보안을 감사하는 데 도움이 되는 팁과 핵심 사항을 제공합니다. 우리는 절대적인 것을 창조한다는 것을 이해해야 합니다.

THE 통화는 어떤 통화에 투자할 가치가 있나요? THE 통화는 어떤 통화에 투자할 가치가 있나요? Feb 21, 2024 pm 03:49 PM

THE(Tokenized Healthcare Ecosystem)는 블록체인 기술을 사용하여 의료 산업의 혁신과 개혁에 초점을 맞춘 디지털 통화입니다. THE 코인의 임무는 블록체인 기술을 사용하여 의료 산업의 효율성과 투명성을 향상시키고 환자, 의료진, 제약 회사 및 의료 기관을 포함한 모든 당사자 간의 보다 효율적인 협력을 촉진하는 것입니다. THE Coin의 가치와 특징 우선, THE Coin은 디지털 화폐로서 블록체인의 장점(분권화, 높은 보안성, 투명한 거래 등)을 갖고 있어 참여자들이 이 시스템을 신뢰하고 의존할 수 있습니다. 둘째, THE 코인의 독창성은 의료 및 건강 산업에 초점을 맞추고 블록체인 기술을 사용하여 전통적인 의료 시스템을 변화시키고 개선한다는 것입니다.

Linux 시스템에서 ntfs 디스크를 마운트할 때 '모듈 퓨즈를 찾을 수 없음' 문제를 해결하는 방법은 무엇입니까? Linux 시스템에서 ntfs 디스크를 마운트할 때 '모듈 퓨즈를 찾을 수 없음' 문제를 해결하는 방법은 무엇입니까? Dec 31, 2023 pm 03:17 PM

1. 먼저 Linux 시스템 커널 [root@localhost~]#uname-r-p2.6.18-194.el5i6862를 확인하여 http://sourceforge.net/projects/linux-ntfs/files/로 이동하여 rpm 패키지를 다운로드합니다. 해당 커널 중 정확히 동일한 커널을 찾을 수 없으면 가장 가까운 커널을 찾을 수 있습니다. 내가 다운로드한 것과 똑같은 것을 찾을 수 없습니다: kernel-module-ntfs-2.6.18-128.1.1.el5-2.1.27-0.rr.10.11.i686.rpm3 rpm 패키지를 설치합니다. -ivhkernel -m

Drupal 기반의 Golang 학습 웹 애플리케이션 개발 Drupal 기반의 Golang 학습 웹 애플리케이션 개발 Jun 24, 2023 am 11:16 AM

모바일 인터넷의 발전으로 웹 애플리케이션에 대한 수요가 계속 증가하고 있으며 효율적이고 빠르며 안전한 프로그래밍 언어인 Golang은 점차 웹 애플리케이션 개발에서 새로운 선호 대상이 되었습니다. 이 기사에서는 Golang을 사용하여 Drupal 기반 웹 애플리케이션을 개발하는 방법을 소개합니다. 1. Drupal이란 무엇입니까? Drupal은 전자상거래 웹사이트, 기업 포털, 커뮤니티 포털 등 다양한 웹 애플리케이션을 구축하는 데 사용할 수 있는 PHP 기반의 오픈 소스 콘텐츠 관리 프레임워크입니다. 드루

See all articles