I am trying to figure out how nodes are mapped back to the fields they contain for learning purposes. How is this done?
我试图弄清楚节点如何映射回它们包含的字段用于学习目的。这是怎么做到的?
1 个解决方案
#1
7
In Drupal 7 you have entities and fields; fields are attached to entities. A node is an implementation of an entity (the node module implements hook_entity_info()
and other such hooks) so it can have fields.
在Drupal 7中你有实体和领域;字段附加到实体。节点是实体的实现(节点模块实现hook_entity_info()和其他此类挂钩),因此它可以具有字段。
All field/entity relational data is stored in the tables field_data_field_x
and field_revision_field_x
or similar (the latter potentially storing revisions of field data if node revisions are enabled).
所有字段/实体关系数据存储在表field_data_field_x和field_revision_field_x或类似的表中(如果启用了节点修订,则后者可能存储字段数据的修订)。
The entity_id
column in those tables is the node's ID, and the bundle
is the node's content type. The revision_id
is the revision ID of the node, again only really useful if node revisions are enabled.
这些表中的entity_id列是节点的ID,bundle是节点的内容类型。 revision_id是节点的修订版ID,仅在启用了节点修订版时才非常有用。
UPDATE
In Drupal terminology a content type is a bundle
and bundle
s are attached to entities (in this case the node
entity). When you create a new content type it gets stored in the node_type
table, and when the caches are cleared (which invokes hook_entity_info
on all modules) the node_entity_info()
function builds up a list of bundles from the content types (have a look at the bit in that function that starts foreach (node_type_get_names() as $type => $name) {
, node_type_get_names
gets a list of all content types).
在Drupal术语中,内容类型是捆绑包,捆绑包附加到实体(在本例中为节点实体)。当您创建新的内容类型时,它将存储在node_type表中,并且当清除缓存(在所有模块上调用hook_entity_info)时,node_entity_info()函数会根据内容类型构建一个包列表(请查看位于启动foreach的函数中的位(node_type_get_names()为$ type => $ name){,node_type_get_names获取所有内容类型的列表)。
As discussed above fields can be attached to entities, so fields can be attached to nodes with a delta (if you like) of bundle
.
如上所述,字段可以附加到实体,因此字段可以附加到具有delta(如果您愿意)bundle的节点。
#1
7
In Drupal 7 you have entities and fields; fields are attached to entities. A node is an implementation of an entity (the node module implements hook_entity_info()
and other such hooks) so it can have fields.
在Drupal 7中你有实体和领域;字段附加到实体。节点是实体的实现(节点模块实现hook_entity_info()和其他此类挂钩),因此它可以具有字段。
All field/entity relational data is stored in the tables field_data_field_x
and field_revision_field_x
or similar (the latter potentially storing revisions of field data if node revisions are enabled).
所有字段/实体关系数据存储在表field_data_field_x和field_revision_field_x或类似的表中(如果启用了节点修订,则后者可能存储字段数据的修订)。
The entity_id
column in those tables is the node's ID, and the bundle
is the node's content type. The revision_id
is the revision ID of the node, again only really useful if node revisions are enabled.
这些表中的entity_id列是节点的ID,bundle是节点的内容类型。 revision_id是节点的修订版ID,仅在启用了节点修订版时才非常有用。
UPDATE
In Drupal terminology a content type is a bundle
and bundle
s are attached to entities (in this case the node
entity). When you create a new content type it gets stored in the node_type
table, and when the caches are cleared (which invokes hook_entity_info
on all modules) the node_entity_info()
function builds up a list of bundles from the content types (have a look at the bit in that function that starts foreach (node_type_get_names() as $type => $name) {
, node_type_get_names
gets a list of all content types).
在Drupal术语中,内容类型是捆绑包,捆绑包附加到实体(在本例中为节点实体)。当您创建新的内容类型时,它将存储在node_type表中,并且当清除缓存(在所有模块上调用hook_entity_info)时,node_entity_info()函数会根据内容类型构建一个包列表(请查看位于启动foreach的函数中的位(node_type_get_names()为$ type => $ name){,node_type_get_names获取所有内容类型的列表)。
As discussed above fields can be attached to entities, so fields can be attached to nodes with a delta (if you like) of bundle
.
如上所述,字段可以附加到实体,因此字段可以附加到具有delta(如果您愿意)bundle的节点。