Skip to content
Snippets Groups Projects
Commit e198c336 authored by Kevin Paxman's avatar Kevin Paxman Committed by Kevin Paxman
Browse files

ISTWCMS-4939: change update to only update default settings to old number

parent 33db82d6
No related branches found
No related tags found
1 merge request!129Feature/istwcms 4939 ebremner listing blocks num items
...@@ -242,22 +242,24 @@ function _uw_cfg_common_create_term($taxonomy_name, $vocab_machine_name, $weight ...@@ -242,22 +242,24 @@ function _uw_cfg_common_create_term($taxonomy_name, $vocab_machine_name, $weight
} }
/** /**
* Set default settings for listing page blocks. * For listing page blocks items per page, when default settings were used,
* change to the original default number of items.
*/ */
function uw_cfg_common_update_8101() { function uw_cfg_common_update_8101() {
// Block ids that need to be changed. // Block ids that need to be changed, and what the original default was.
// For some reason, we didn't originally use the same number for everything.
$block_ids = [ $block_ids = [
'views_block:uw_view_blogs-blogs_listing_block', 'views_block:uw_view_blogs-blogs_listing_block' => 5,
'views_block:uw_view_events-events_listing_block', 'views_block:uw_view_events-events_listing_block' => 10,
'views_block:uw_view_news_items-news_items_listing_block', 'views_block:uw_view_news_items-news_items_listing_block' => 10,
]; ];
// Load all the nodes. // Load all the nodes.
$nodes = Node::loadMultiple(); $nodes = Node::loadMultiple();
// Step through each node and set the default setting // Step through each node and set any that were using the default setting
// to 3 on listing blocks. // to the number that was the default before this change.
foreach ($nodes as $node) { foreach ($nodes as $node) {
// Flag to save the node, have this to save processing // Flag to save the node, have this to save processing
...@@ -279,19 +281,16 @@ function uw_cfg_common_update_8101() { ...@@ -279,19 +281,16 @@ function uw_cfg_common_update_8101() {
// If this component is one that needs to be changed, // If this component is one that needs to be changed,
// then check for setting and change if required. // then check for setting and change if required.
if (in_array($component->getPluginId(), $block_ids)) { if (in_array($component->getPluginId(), array_keys($block_ids))) {
// Load the config for the block. // Load the config for the block.
$configurations = $component->get('configuration'); $configurations = $component->get('configuration');
// If the config is none of 5, it needs to be changed to 3. // If the config is set to "none", it needs to be changed to
if ( // be set to the number that was the old default value.
$configurations['items_per_page'] == 'none' || if ($configurations['items_per_page'] == 'none') {
$configurations['items_per_page'] == '5'
) {
// Change the config and save the component. // Change the config and save the component.
$configurations['items_per_page'] = '3'; $configurations['items_per_page'] = $block_ids[$component->getPluginId()];
$component->setConfiguration($configurations); $component->setConfiguration($configurations);
// Set the save node flag so that we know to // Set the save node flag so that we know to
......
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