Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
manage_display
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
manage_display
Commits
0aca47f4
Commit
0aca47f4
authored
6 years ago
by
AdamPS
Browse files
Options
Downloads
Patches
Plain Diff
Minor comment changes, comment out all the speculative code for now
parent
283b4e07
Branches
Branches containing commit
Tags
8.x-1.0-alpha6
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
manage_display.module
+25
-22
25 additions, 22 deletions
manage_display.module
with
25 additions
and
22 deletions
manage_display.module
+
25
−
22
View file @
0aca47f4
...
...
@@ -16,6 +16,7 @@ use Drupal\node\Entity\NodeType;
*/
function
manage_display_entity_type_build
(
array
&
$entity_types
)
{
$entity_types
[
'node'
]
->
set
(
'node_basefield_skip_preprocess'
,
TRUE
);
// Set user name as a label else it gets printed twice on the user page.
$keys
=
$entity_types
[
'user'
]
->
get
(
'entity_keys'
);
$keys
[
'label'
]
=
'name'
;
...
...
@@ -67,32 +68,32 @@ function manage_display_entity_base_field_info_alter(&$base_field_definitions, E
/**
* Implements hook_entity_view().
*/
function
manage_display_entity_view
(
array
&
$build
,
EntityInterface
$entity
,
EntityViewDisplayInterface
$display
,
$view_mode
)
{
if
(
$entity
instanceof
FieldableEntityInterface
)
{
$label_field
=
$entity
->
getEntityType
()
->
getKey
(
'label'
);
if
(
isset
(
$build
[
$label_field
]))
{
//
$build[$label_field]['#pre_render'][] = 'manage_display_title_pre_render';
//
@todo If want to keep the field in the entity.
//
Requires a change to EntityViewController::buildTitle
//
$build['#built_page_title'] = TRUE;
//
@todo If also want to hide title block.
//
But loses metadata - better to prevent only title block.
//
$build['#title'] = '';
//
??$build['#title'] = new HtmlEscapedText($entity->label());
}
}
}
//
function manage_display_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
//
if ($entity instanceof FieldableEntityInterface) {
//
$label_field = $entity->getEntityType()->getKey('label');
//
if (isset($build[$label_field])) {
//
$build[$label_field]['#pre_render'][] = 'manage_display_title_pre_render';
//
@todo If want to keep the field in the entity.
//
Requires a change to EntityViewController::buildTitle
//
$build['#built_page_title'] = TRUE;
//
@todo If also want to hide title block.
//
But loses metadata - better to prevent only title block.
//
$build['#title'] = '';
//
??$build['#title'] = new HtmlEscapedText($entity->label());
//
}
//
}
//
}
/**
* Implements pre_render callback for entity.
*/
function
manage_display_title_pre_render
(
array
$build
)
{
if
(
isset
(
$build
[
'#is_page_title'
]))
{
// @todo Ensure markup is inline: swap formatter etc. Workaround for https://www.drupal.org/node/2941208.
// Is this too late, as it has already been built? Instead hook_entity_view_display_alter?
}
return
$build
;
}
//
function manage_display_title_pre_render(array $build) {
//
if (isset($build['#is_page_title'])) {
//
// @todo Ensure markup is inline: swap formatter etc. Workaround for https://www.drupal.org/node/2941208.
//
// Is this too late, as it has already been built? Instead hook_entity_view_display_alter?
//
}
//
return $build;
//
}
/**
* Return information about the base fields that can be managed.
...
...
@@ -163,6 +164,7 @@ function template_preprocess_submitted(&$variables) {
$variables
[
'date'
][
'#inline_field'
]
=
TRUE
;
$variables
[
'date'
]
=
\Drupal
::
service
(
'renderer'
)
->
render
(
$variables
[
'date'
]);
// @todo This doesn't fully work with quickedit - when the field gets re-rendered after edit, the date is missing.
// Detect this case with a field preprocess hook and make a call to render the date.
// Drupal core doesn't fully work either: the user picture doesn't get re-rendered.
}
}
...
...
@@ -171,6 +173,7 @@ function template_preprocess_submitted(&$variables) {
* Implements hook_preprocess_node().
*/
function
manage_display_preprocess_node
(
&
$variables
)
{
// @todo generalise this to any entity type. Read entity_keys to find the field names.
// Move date into the created element.
if
(
isset
(
$variables
[
'content'
][
'uid'
][
'#formatter'
])
&&
(
$variables
[
'content'
][
'uid'
][
'#formatter'
]
==
'submitted'
))
{
if
(
isset
(
$variables
[
'content'
][
'created'
]))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment