Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Commits
59c3a16a
Commit
59c3a16a
authored
3 years ago
by
Eric Bremner
Committed by
Igor Biki
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5195: adding function to get formatted text
parent
dcfb2d15
No related branches found
No related tags found
1 merge request
!169
Feature/istwcms 5195 ebremner node theming
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Service/UwNodeFieldValue.php
+22
-6
22 additions, 6 deletions
src/Service/UwNodeFieldValue.php
with
22 additions
and
6 deletions
src/Service/UwNodeFieldValue.php
+
22
−
6
View file @
59c3a16a
...
@@ -86,7 +86,7 @@ class UwNodeFieldValue {
...
@@ -86,7 +86,7 @@ class UwNodeFieldValue {
// Long text field type with a text format.
// Long text field type with a text format.
if
(
$type
==
'formatted_text'
)
{
if
(
$type
==
'formatted_text'
)
{
return
$node
->
$field_name
->
getValue
()[
0
]
;
return
$this
->
getFormattedText
(
$node
,
$field_name
)
;
}
}
// Only content, either layout builder or summary.
// Only content, either layout builder or summary.
...
@@ -151,6 +151,25 @@ class UwNodeFieldValue {
...
@@ -151,6 +151,25 @@ class UwNodeFieldValue {
}
}
}
}
/**
* Function to get the formatted text.
*
* @param \Drupal\node\Entity\Node $node
* The node.
* @param string $field_name
* The name of the field to get.
*
* @return array
* Render array for formatted text.
*/
public
function
getFormattedText
(
Node
$node
,
string
$field_name
):
array
{
return
[
'#type'
=>
'processed_text'
,
'#text'
=>
$node
->
$field_name
->
value
,
'#format'
=>
$node
->
$field_name
->
format
,
];
}
/**
/**
* Function to get catalog tags.
* Function to get catalog tags.
*
*
...
@@ -273,12 +292,9 @@ class UwNodeFieldValue {
...
@@ -273,12 +292,9 @@ class UwNodeFieldValue {
*/
*/
public
function
getContentField
(
Node
$node
,
string
$view_mode
,
string
$field_name
)
{
public
function
getContentField
(
Node
$node
,
string
$view_mode
,
string
$field_name
)
{
// If on the teaser, return the summary field values.
if
(
$view_mode
==
'teaser'
)
{
if
(
$view_mode
==
'teaser'
)
{
return
[
return
$this
->
getFormattedText
(
$node
,
$field_name
);
'#type'
=>
'processed_text'
,
'#text'
=>
$node
->
$field_name
->
value
,
'#format'
=>
$node
->
$field_name
->
format
,
];
}
}
return
NULL
;
return
NULL
;
...
...
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