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?

ithcyithcy New
edited September 2010 in Vanilla 2.0 - 2.8
@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.
Tagged:

Comments

  • TimTim Vanilla Staff
    If I were you, I would hook one of the earlier events in the PluginController page and just add a < div > containing your configuration requirement message.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • yeah, good idea. any news on that developer plugin that was discussed earlier, that shows the available event hooks on the page?
  • TimTim Vanilla Staff
    I've completed it but it depends on 2.0.10a. You'd need to pull that.

    Let me upload the dev plugin quickly.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • awesome. i like the name.
  • TimTim Vanilla Staff
    :D

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • ithcyithcy New
    edited September 2010
    OK, I've got something working thanks to eventi, but it still feels hackish. i guess I don't fully understand how to hook into certain events.

    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?
  • TimTim Vanilla Staff
    public function SettingsController_BeforeRenderAsset_Handler($Sender) { echo "shranp"; }

    ?

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • That was one of the permutations I tried. No output. I'll give it another go tomorrow. Thanks!
  • ithcyithcy New
    edited September 2010
    Sorry, I was mistaken. I was already using SettingsController_BeforeRenderAsset_Handler. That event fires all over the place, everywhere you see red in this screenshot.

    image

    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') . ''; } }
Sign In or Register to comment.