How to store node content in Drupal
You will be surprised when you look at the node table in Drupal. That is because you can not find the content field which is used to store the content. In fact, Drupal uses field API to store the content. Frankly speaking, this is a good design and one of Drupal's advantage. You can understand node as the base table and it can be extended in other tables.
In the following, i will use Blog module to make in-depth explanation.
1. Declare blog node type
[html]
function blog_node_info() {
return array(
'blog' => array(
'name' => t('Blog entry'),
'base' => 'blog',
'description' => t('Use for multi-user blogs. Every user gets a personal blog.'),
)
);
}
From Node API, we can know that hook_node_info is to define module-provided node types.The base key-value entry in the array means that it will use blog prefix hook at first priority for the node operation callback.
2. Attach the body field to blog node type
[html]
function blog_install() {
// Ensure the blog node type is available.
node_types_rebuild();
$types = node_type_get_types();
node_add_body_field($types['blog']);
}
node_types_rebuild method's task is to collect the data from the modules which implements hook_node_info, then save the data into table node_type and put the data into cache for instant usage.
For function node_add_body_field, it is necessary to look its function body.
[html]
function node_add_body_field($type, $label = 'Body') {
// Add or remove the body field, as needed.
$field = field_info_field('body');
$instance = field_info_instance('node', 'body', $type->type);
return $instance;
}
From the code statements, they are apparently self-explaining. It loads the field body's information and create an instance, then attach the instance to blog node type. I will explore field API and Node type UI (filed and node rendering) next time to make it as complete story.

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









nvm でノードを削除する方法: 1. 「nvm-setup.zip」をダウンロードして C ドライブにインストールします; 2. 「nvm -v」コマンドで環境変数を構成し、バージョン番号を確認します; 3. 「nvm」を使用しますinstall" コマンド ノードのインストール; 4. "nvm uninstall" コマンドでインストールしたノードを削除します。

ファイルのアップロードをどのように処理するか?次の記事では、Express を使用してノード プロジェクトでファイルのアップロードを処理する方法を紹介します。

この記事では、Node のプロセス管理ツール「pm2」について説明し、pm2 が必要な理由、pm2 のインストール方法と使用方法について説明します。皆様のお役に立てれば幸いです。

ピン張りのノードの詳細な説明とインストールガイドこの記事では、ピネットワークのエコシステムを詳細に紹介します - PIノードは、ピン系生態系における重要な役割であり、設置と構成の完全な手順を提供します。 Pinetworkブロックチェーンテストネットワークの発売後、PIノードは多くの先駆者の重要な部分になり、テストに積極的に参加し、今後のメインネットワークリリースの準備をしています。まだピン張りのものがわからない場合は、ピコインとは何かを参照してください。リストの価格はいくらですか? PIの使用、マイニング、セキュリティ分析。パインワークとは何ですか?ピン競技プロジェクトは2019年に開始され、独占的な暗号通貨PIコインを所有しています。このプロジェクトは、誰もが参加できるものを作成することを目指しています

Nodejs実行可能ファイルをpkgでパッケージ化するにはどうすればよいですか?次の記事では、pkg を使用して Node プロジェクトを実行可能ファイルにパッケージ化する方法を紹介します。
![Microsoft Store を開けず、「申し訳ありませんが、問題が発生しましたが、問題は解決しました。」と表示される - [詳細な解決策]](https://img.php.cn/upload/article/000/887/227/171151687965989.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
一部のユーザーは、Microsoft Store でお気に入りのアプリを見つけてダウンロードしてインストールしたいと考えていますが、Microsoft Store を開くことができず、「申し訳ありません。問題が発生しましたが、正常に完了しました。」というメッセージも表示されます。問題を解決して開くことができますか? Microsoft Store はバックアップされて実行されていますか?編集者は以下の 2 つの方法をまとめました。お役に立てれば幸いです。方法 1 では、Win+R を押して「cmd」と入力し、ctrl+shift を押しながら「OK」をクリックし (UAC がポップアップ表示されたら「はい」をクリック)、cmd ウィンドウが表示され (管理者モード)、次の内容をコピーして貼り付けます: netshwinsockresetnetshintipresetipconfig/ releaseipconfig/renewi

「node-gyp.js」が「Node.js」のバージョンと一致しないため、npm node gyp が失敗します。解決策は次のとおりです: 1. 「npm cache clean -f」を使用してノード キャッシュをクリアします; 2. 「npm install -」を使用します。 g n" n モジュールをインストールします。 3. 「n v12.21.0」コマンドを使用して、「node v12.21.0」バージョンをインストールします。

シングルサインオンシステムとは何ですか? Nodejsを使用して実装するにはどうすればよいですか?次の記事ではnodeを使ってシングルサインオンシステムを実現する方法を紹介しますので、参考になれば幸いです。
