Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_custom_blocks
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_custom_blocks
Commits
27eef099
Commit
27eef099
authored
6 months ago
by
Lily Yan
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-7116 Remove 'In catalog' if selecting the checkbox
parent
b9b57a71
No related branches found
No related tags found
1 merge request
!249
ISTWCMS-7116 Add option to disable showing which catalog an item is from in listing blocks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Service/UwBlockManualRender.php
+58
-28
58 additions, 28 deletions
src/Service/UwBlockManualRender.php
with
58 additions
and
28 deletions
src/Service/UwBlockManualRender.php
+
58
−
28
View file @
27eef099
...
@@ -256,48 +256,78 @@ class UwBlockManualRender {
...
@@ -256,48 +256,78 @@ class UwBlockManualRender {
*/
*/
private
function
getCatalogItemRender
(
array
$config
):
array
{
private
function
getCatalogItemRender
(
array
$config
):
array
{
//
Get
the view
for catalog items
.
//
Load
the view.
$view
=
$this
->
entityTypeManager
$view
=
$this
->
entityTypeManager
->
getStorage
(
'view'
)
->
getStorage
(
'view'
)
->
load
(
'uw_view_catalog_search'
)
->
load
(
'uw_view_catalog_search'
)
->
getExecutable
();
->
getExecutable
();
// Set the display to the embed view.
// Load the correct view display, based on if a
$view
->
setDisplay
(
'catalog_search_all_embed'
);
// catalog was entered.
// If there are catalog items, add them to the
// contextual filter of the view.
if
(
if
(
isset
(
$config
[
'catalog_item'
][
'catalog
_item_ids
'
])
&&
isset
(
$config
[
'catalog_item'
][
'
in_
catalog'
])
&&
count
(
$config
[
'catalog_item'
][
'catalog
_item_ids'
])
>
0
$config
[
'catalog_item'
][
'
in_
catalog
'
]
==
1
)
{
)
{
// The catalog id contextual filter value.
// Set the display unset the all items flag.
$catalog_ids
=
''
;
$view
->
setDisplay
(
'search_specific_embed'
);
// Set the catalog argument list.
$catalog_arg_list
=
$this
->
uwBlockService
->
getTermList
(
$config
[
'catalog'
]);
// Get the catalog filter, set the value and set the handler.
$filter
=
$view
->
getHandler
(
'search_specific_embed'
,
'filter'
,
'field_uw_catalog_catalog_target_id'
);
$filter
[
'value'
]
=
explode
(
','
,
$catalog_arg_list
);
$view
->
setHandler
(
'search_specific_embed'
,
'filter'
,
'field_uw_catalog_catalog_target_id'
,
$filter
);
}
else
{
//
Counter used to add the + sign in between filters
.
//
Set the display to the embed view
.
$
counter
=
0
;
$
view
->
setDisplay
(
'catalog_search_all_embed'
)
;
// Step through each of the catalog item ids and add them
// If there are catalog items, add them to the
// to the catalog ids filter value.
// contextual filter of the view.
foreach
(
$config
[
'catalog_item'
][
'catalog_item_ids'
]
as
$catalog_item_id
)
{
if
(
isset
(
$config
[
'catalog_item'
][
'catalog_item_ids'
])
&&
count
(
$config
[
'catalog_item'
][
'catalog_item_ids'
])
>
0
)
{
//
If we are past the first value add the plus sign so
//
The catalog id contextual filter value.
// that the contextual filters work correctly.
$catalog_ids
=
''
;
if
(
$counter
>
0
)
{
$catalog_ids
.
=
'+'
;
// Counter used to add the + sign in between filters.
}
$counter
=
0
;
// Add the value to the filters.
// Step through each of the catalog item ids and add them
$catalog_ids
.
=
$catalog_item_id
[
'id'
];
// to the catalog ids filter value.
foreach
(
$config
[
'catalog_item'
][
'catalog_item_ids'
]
as
$catalog_item_id
)
{
// Increment the counter so we get the plus sign if required.
// If we are past the first value add the plus sign so
$counter
++
;
// that the contextual filters work correctly.
}
if
(
$counter
>
0
)
{
$catalog_ids
.
=
'+'
;
}
// If there are catalog id filters, add to the view.
// Add the value to the filters.
if
(
$catalog_ids
)
{
$catalog_ids
.
=
$catalog_item_id
[
'id'
];
$view
->
setArguments
([
$catalog_ids
]);
// Increment the counter so we get the plus sign if required.
$counter
++
;
}
// If there are catalog id filters, add to the view.
if
(
$catalog_ids
)
{
$view
->
setArguments
([
$catalog_ids
]);
}
}
}
}
}
...
...
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