Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_dashboard
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
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_dashboard
Commits
cee2dbee
Commit
cee2dbee
authored
1 year ago
by
Eric Bremner
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-6771: fixing content list block to use views ajax
parent
583de8ac
No related branches found
No related tags found
1 merge request
!32
Feature/istwcms 6771 ebremner dashboard ajax
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/Block/ContentListBlock.php
+16
-9
16 additions, 9 deletions
src/Plugin/Block/ContentListBlock.php
with
16 additions
and
9 deletions
src/Plugin/Block/ContentListBlock.php
+
16
−
9
View file @
cee2dbee
...
...
@@ -85,11 +85,14 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
// The build array.
$build
=
[];
// The display id of the view to be used.
$display_id
=
'content_list'
;
// Get the view by machine id.
$view
=
Views
::
getView
(
'uw_view_content_list'
);
// Set the display machine id.
$view
->
setDisplay
(
'content_list'
);
$view
->
setDisplay
(
$display_id
);
// Add the content type restriction to the arguments.
$arguments
[]
=
$this
->
configuration
[
'content_type'
];
...
...
@@ -153,23 +156,27 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
);
}
// Execute the view.
$view
->
execute
();
// Get the title.
$title
=
$view
->
getTitle
();
// Get the rendered view.
$render
=
$view
->
render
();
// Get the rendered title for the view.
$the_title_render_array
=
[
'#markup'
=>
$this
->
t
(
'@title'
,
[
'@title'
=>
$title
]),
'#allowed_tags'
=>
[
'h2'
],
];
// Set the build markup for title and actual view.
$build
[
'view_title'
]
=
$the_title_render_array
;
$build
[
'view_output'
]
=
$render
;
return
$build
;
// Display using the view template so ajax works properly.
return
[
'#type'
=>
'view'
,
'#name'
=>
$the_title_render_array
,
'#view'
=>
$view
,
'#display_id'
=>
$display_id
,
'#embed'
=>
TRUE
,
'#cache'
=>
$view
->
getCacheTags
(),
];
}
/**
...
...
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