I would like to set additional options for a widget upon registration and have those options propagate to existing widgets of that type. I have this code in my plugin_init(), where the definition includes 'option_name' => 'option value'.
elgg_register_widget_type([
'id' => 'my_widget'
,'name' => 'my widget'
,'description' => 'My widget'
,'context' => ['dashboard']
,'option_name' => 'option value'
]);
I thought I would find the new option_name and 'option value' in the private_settings table for the associated widgets, but I don't. Neither do I see it as $widget->option_name value. I thought (hoped) that propagation to the widget would happen when Widget Manager's applyWidgetsConfig hook handler triggers.
Do you have any advice for setting and getting default widget options?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- C0Rrupt@thjMMvw
C0Rrupt - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
You must log in to post replies.function elgg_register_widget_type() isn't apply this param.
Thanks Nikolai. That's what I discovered. Do you have any advice for setting and getting default widget options?
1. You can use widget_settings, <widget_handler> hook:
Look at this example.
2. Widget is an entity, so you can use it as the usual object via setting/getting metadata.
Of course, you need to know a GUID for this.
3. Don't forget, you can override the edit form of your widget by setting the default values before the user has done so.