Skip to content
Snippets Groups Projects
Commit b9b57a71 authored by Lily Yan's avatar Lily Yan
Browse files

ISTWCMS-7116 Add in_catalog checkbox for manual list catalog item block

parent a0f09c28
No related branches found
No related tags found
1 merge request!249ISTWCMS-7116 Add option to disable showing which catalog an item is from in listing blocks
......@@ -118,6 +118,15 @@ class UwBlockManualElements {
);
}
// The catalog item content type should have 'in catalog' checkbox.
if ($ct == 'catalog_item') {
// The form element for show the title.
$form[$ct]['in_catalog'] = $this->uwBlockService->getShowInCatalogFormElement(
$ct,
$config
);
}
// Set the nids.
$this->getManualBlockNodeFormElement(
$form,
......
......@@ -68,6 +68,10 @@ class UwBlockManualGetConfig {
$config['show_image'] = $values[$content_type]['show_image'] ?? 0;
$config[$ids_name] = $ids;
// If this is a catalog item, then store in_catalog into the config.
if ($content_type == 'catalog_item') {
$config['in_catalog'] = $values[$content_type]['in_catalog'] ?? 0;
}
// If this is an event, then store the style into the config.
if ($content_type == 'event') {
$config['style'] = $values[$content_type]['style'];
......
......@@ -140,6 +140,10 @@ class UwBlockManualRender {
$items['type'] = 'events';
$items['style'] = $config['event']['style'] == 'agenda' ? 'uw-agenda' : '';
}
elseif ($content_type == 'catalog_item') {
$items['type'] = 'catalog_item';
$items['in_catalog'] = $config['catalog_item']['in_catalog'];
}
else {
$items['type'] = $content_type;
}
......
......@@ -183,6 +183,27 @@ class UwBlockService {
];
}
/**
* Function to get the in catalog form element.
*
* @param string $name
* The name of the element.
* @param array $config
* The config for the block.
*
* @return array
* The in catalog form element.
*/
public function getShowInCatalogFormElement(string $name, array $config): array {
// The form element for show the title.
return [
'#type' => 'checkbox',
'#title' => $this->t('Remove "In catalog" indicator'),
'#default_value' => $config[$name]['in_catalog'] ?? 0,
];
}
/**
* Function to get taxonomy term form element.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment