Explore block module in Drupal
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);
}
}

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

熱門話題

Moondrop 為音頻愛好者發布了 Block 真無線耳機,可舒適地佩戴在外耳中。與塞入耳道的耳塞不同,Block 不會造成耳朵堵塞的感覺或積聚耳垢。隨附 13 毫米驅動器

機器之能報道編輯:吳昕國內版的人形機器人+大模型組隊,首次完成疊衣服這類複雜柔性材料的操作任務。隨著融合了OpenAI多模態大模型的Figure01揭開神秘面紗,國內同行的相關進展一直備受關注。就在昨天,國內"人形機器人第一股"優必選發布了人形機器人WalkerS深入融合百度文心大模型後的首個Demo,展示了一些有趣的新功能。現在,得到百度文心大模型能力加持的WalkerS是這個樣子的。和Figure01一樣,WalkerS沒有走動,而是站在桌子後面完成一系列任務。它可以聽從人類的命令,折疊衣物

在Python的開發過程中,常常會遇到找不到模組的錯誤。這個錯誤的具體表現就是Python在導入模組的時候報出ModuleNotFoundError或ImportError這兩個錯誤之一。這種錯誤很困擾,會導致程式無法正常運作,因此在這篇文章裡,我們將會探討這個錯誤的原因及其解決方法。 ModuleNotFoundError和ImportError在Pyth

在Java9版本中Java語言引入了一個非常重要的概念:模組(module)。如果對javascript程式碼模組化管理比較熟悉的小夥伴,看到Java9的模組化管理,應該會有似曾相識的感覺。一、什麼是Javamodule?與Java中的package有些類似,module引入了Java程式碼分組的另一個層級。每個這樣的分組(module)都包含許多子package套件。透過在一個模組的原始碼檔案package的根部,加入檔案module-info.java來聲明該資料夾及其子資料夾為一個模組。該文件語法

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包rpm-ivhkernel -m

THE是什麼幣種?THE(TokenizedHealthcareEcosystem)是一種數位貨幣,利用區塊鏈技術,專注於醫療健康產業的創新和改革。 THE幣的使命是利用區塊鏈技術來提高醫療產業的效率和透明度,推動各方之間更有效率的合作,包括病患、醫護人員、製藥公司和醫療機構。 THE幣的價值和特徵首先,THE幣作為一種數位貨幣,具備了區塊鏈的優勢——去中心化、安全性高、交易透明等,讓參與者能夠信任和依賴這個系統。其次,THE幣的獨特之處在於它專注於醫療健康產業,並藉助區塊鏈技術改造了傳統醫療體系,提升了

Drupal配置Drupal是一個開源的PHP內容管理系統,有著相當複雜的架構。它還具有強大的安全模型。感謝開發人員在社群的貢獻和維護,所以有很多詳細的文件和有關加強Drupal網站安全配置的方法。切記,Drupal是經營網站所需的一部分。為了保護整個系統免受駭客攻擊,我們需要處理整套系統。它包括一些常見的伺服器設置,Web伺服器的配置,PHP和資料庫。此外,伺服器上的任何其他服務都需要正確配置。它提供了一些提示和關鍵點,可以幫助伺服器和網站管理員審核整個系統的安全性。我們應該明白,打造一個絕對

如何透過PHP-FPM優化來提高Drupal網站的效能摘要:Drupal是一個功能強大的內容管理系統,但在處理大量請求時可能會出現效能瓶頸。本文將介紹如何使用PHP-FPM來最佳化Drupal網站的效能,包括調整PHP-FPM的設定參數、使用進程管理器和使用快取等方法,同時給出特定的程式碼範例。調整PHP-FPM的設定參數提高PHP-FPM的最大進程數和最大請求數
