Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
2e438914
Commit
2e438914
authored
Nov 21, 2010
by
Dries Buytaert
Browse files
- Patch
#830020
by chx, yched: field_get_display() does not get the entity.
parent
df5714f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
modules/field/field.api.php
View file @
2e438914
...
...
@@ -2165,6 +2165,7 @@ function hook_field_info_max_weight($entity_type, $bundle, $context) {
* - entity_type: The entity type; e.g. 'node' or 'user'.
* - field: The field being rendered.
* - instance: The instance being rendered.
* - entity: The entity being rendered.
* - view_mode: The view mode, e.g. 'full', 'teaser'...
*
* @see hook_field_display_ENTITY_TYPE_alter()
...
...
@@ -2199,6 +2200,7 @@ function hook_field_display_alter(&$display, $context) {
* - entity_type: The entity type; e.g. 'node' or 'user'.
* - field: The field being rendered.
* - instance: The instance being rendered.
* - entity: The entity being rendered.
* - view_mode: The view mode, e.g. 'full', 'teaser'...
*
* @see hook_field_display_alter()
...
...
modules/field/field.default.inc
View file @
2e438914
...
...
@@ -142,7 +142,7 @@ function field_default_prepare_view($entity_type, $entities, $field, $instances,
foreach
(
$instances
as
$id
=>
$instance
)
{
if
(
is_string
(
$display
))
{
$view_mode
=
$display
;
$display
=
field_get_display
(
$instance
,
$view_mode
);
$display
=
field_get_display
(
$instance
,
$view_mode
,
$entities
[
$id
]
);
}
if
(
$display
[
'type'
]
!==
'hidden'
)
{
$module
=
$display
[
'module'
];
...
...
@@ -194,7 +194,7 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode,
// Prepare incoming display specifications.
if
(
is_string
(
$display
))
{
$view_mode
=
$display
;
$display
=
field_get_display
(
$instance
,
$view_mode
);
$display
=
field_get_display
(
$instance
,
$view_mode
,
$entity
);
}
else
{
$view_mode
=
'_custom_display'
;
...
...
modules/field/field.module
View file @
2e438914
...
...
@@ -448,11 +448,13 @@ function field_view_mode_settings($entity_type, $bundle) {
* The field instance being displayed.
* @param $view_mode
* The view mode.
* @param $entity
* The entity being displayed.
*
* @return
* The display settings to be used when displaying the field values.
*/
function
field_get_display
(
$instance
,
$view_mode
)
{
function
field_get_display
(
$instance
,
$view_mode
,
$entity
)
{
// Check whether the view mode uses custom display settings or the 'default'
// mode.
$view_mode_settings
=
field_view_mode_settings
(
$instance
[
'entity_type'
],
$instance
[
'bundle'
]);
...
...
@@ -464,6 +466,7 @@ function field_get_display($instance, $view_mode) {
'entity_type'
=>
$instance
[
'entity_type'
],
'field'
=>
field_info_field
(
$instance
[
'field_name'
]),
'instance'
=>
$instance
,
'entity'
=>
$entity
,
'view_mode'
=>
$view_mode
,
);
drupal_alter
(
array
(
'field_display'
,
'field_display_'
.
$instance
[
'entity_type'
]),
$display
,
$context
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment