Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Plugin development: how to notify a user that a plugin needs to be configured?
ithcy
New
@Tim @Todd @Lincoln
While writing a plugin I needed a way to show the user that the plugin needed configuration. I figured a good place for this was in the list of all plugins on the dashboard, where update availability notifications appear for individual plugins.
I figured as a hack I could just dynamically change $PluginInfo['MyPlugin']['Description'] when the configuration item wasn't set, but it looks like that string is filtered before display, so I could not get my changes to show.
Is there a better or sanctioned way to do this? It seems like it must have been done before.
While writing a plugin I needed a way to show the user that the plugin needed configuration. I figured a good place for this was in the list of all plugins on the dashboard, where update availability notifications appear for individual plugins.
I figured as a hack I could just dynamically change $PluginInfo['MyPlugin']['Description'] when the configuration item wasn't set, but it looks like that string is filtered before display, so I could not get my changes to show.
Is there a better or sanctioned way to do this? It seems like it must have been done before.
Tagged:
0
Comments
Vanilla Forums COO [GitHub, Twitter, About.me]
Let me upload the dev plugin quickly.
Vanilla Forums COO [GitHub, Twitter, About.me]
Vanilla Forums COO [GitHub, Twitter, About.me]
Vanilla Forums COO [GitHub, Twitter, About.me]
At a certain spot in the settings controller, the BeforeRenderAsset event is fired, with the AssetName 'Content'. This is just above 'Manage Plugins' on the dashboard. This is where I want to put my message.
I tried various naming schemes hoping to invoke a magic event there, but the only one that seems to work is SettingsController_Render_Before SettingsController_BeforeRenderAsset_Handler. Which sort of makes sense with the naming, except that event also fires in several other places on the page, so I'd get multiple messages.
So what I did was make the SettingsController_Render_BeforeSettingsController_BeforeRenderAsset_Handler function and test if the AssetName is 'Content' before I spit out my div. This feels gross. Is there a better way?
public function SettingsController_BeforeRenderAsset_Handler($Sender) { echo "shranp"; }
?
Vanilla Forums COO [GitHub, Twitter, About.me]
The only way to tame it is to filter by AssetName. Am I asking for a custom event here?
public function SettingsController_BeforeRenderAsset_Handler(&$Sender) {
// if plugin is enabled but Skysa ID has not been set, show a warning.
if (
$Sender->EventArguments['AssetName'] == 'Content' &&
Gdn::Config('EnabledPlugins.Skysa') != '' &&
Gdn::Config('Plugins.Skysa.SkysaID') == ''
) {
$WebRoot = Gdn::Request()->Domain() . '/' . Gdn::Request()->WebRoot();
echo '' . T('SkysaEmptyID') . ''; } }