Skip to content

Commit

Permalink
added: plugin setting to control number of columns in group widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalsem committed May 19, 2022
1 parent 9a4d436 commit ad31c67
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classes/ColdTrick/WidgetManager/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static function updateGroupWidgets(\Elgg\Event $event) {

// enable widgets
$column_counts = [];
$max_columns = elgg_trigger_plugin_hook('groups:column_count', 'widget_manager', [], 2);
$max_columns = elgg_trigger_plugin_hook('groups:column_count', 'widget_manager', [], elgg_get_plugin_setting('group_column_count', 'widget_manager'));
for ($i = 1; $i <= $max_columns; $i++) {
$column_counts[$i] = 0;
}
Expand Down Expand Up @@ -192,7 +192,7 @@ public static function getGroupWidgetsLayout(\Elgg\Hook $hook) {
// need context = groups to fix the issue with the new group_profile context
elgg_push_context('groups');

$num_columns = (int) elgg_extract('num_columns', $vars, 2);
$num_columns = (int) elgg_extract('num_columns', $vars, elgg_get_plugin_setting('group_column_count', 'widget_manager'));

$vars[\Elgg\ViewsService::OUTPUT_KEY] = elgg_view_layout('widgets', [
'num_columns' => $num_columns,
Expand Down
1 change: 1 addition & 0 deletions elgg-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
],
'bootstrap' => \ColdTrick\WidgetManager\Bootstrap::class,
'settings' => [
'group_column_count' => 2,
'widget_layout' => '33|33|33',
'lazy_loading_enabled' => 0,
'lazy_loading_mobile_columns' => 1,
Expand Down
1 change: 1 addition & 0 deletions languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
'widget_manager:settings:group:option_admin_only' => "Only administrator can enable group widgets",
'widget_manager:settings:group:force_tool_widgets' => "Enforce group tool widgets",
'widget_manager:settings:group:force_tool_widgets:confirm' => "Are you sure? This will add/remove all widgets specific to a tool option for all groups (where widget management is enabled).",
'widget_manager:settings:group:group_column_count' => "Number of widget columns in a group",

'widget_manager:settings:extra_contexts:description' => "Enter the page handler name of the new page which will get a layout similar to the index page. You can add as much pages as you need. Be sure not to add a page handler that is already in use. You can also configure the column layout for that page and optionally assign non-admin users as manager of the page.",
'widget_manager:settings:extra_contexts:page' => "Page",
Expand Down
1 change: 1 addition & 0 deletions languages/nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
'widget_manager:settings:group:enable' => 'Schakel Widget Manager in voor groepen',
'widget_manager:settings:group:option_default_enabled' => 'Widgets beheer voor groepen standaard ingeschakeld',
'widget_manager:settings:group:option_admin_only' => 'Alleen beheerders kunnen groep widgets inschakelen',
'widget_manager:settings:group:group_column_count' => 'Aantal widget kolommen in een groep',
'widget_manager:forms:manage_widgets:no_widgets' => 'Geen widgets om te beheren',
'widget_manager:widgets:edit:advanced' => 'Geavanceerd',
'widget_manager:widgets:edit:disable_widget_content_style' => 'Verwijder widget stijl',
Expand Down
7 changes: 7 additions & 0 deletions views/default/plugins/widget_manager/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@
'default' => 'no',
'value' => 'yes',
]);
$group_settings .= elgg_view_field([
'#type' => 'number',
'#label' => elgg_echo('widget_manager:settings:group:group_column_count'),
'name' => 'params[group_column_count]',
'value' => $plugin->group_column_count,
'min' => 1,
]);

echo elgg_view_module('info', elgg_echo('widget_manager:settings:group'), $group_settings);
}
Expand Down

0 comments on commit ad31c67

Please sign in to comment.