Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Modules

ddumontddumont ✭✭
edited October 2011 in Development
I'd love to know more about them.
Can plugins contribute them? If so, how?

My addons: NillaBlog | Vanoogle

Comments

  • LincLinc Vanilla's Bard (and Director of Development) Detroit Vanilla Staff
    Yes, check out Tagging for a good example of bundling a module with a plugin.
  • LincLinc Vanilla's Bard (and Director of Development) Detroit Vanilla Staff
    My way of thinking of them is a mini self-contained view you can easily tuck inside any asset like the 'Panel' (sidebar) or 'Foot'. They're like a more flexible (for a programmer) type of WordPress widget.
  • So I did get one up and running by declaring the module class inside my plugin class file... Does the plugin code pick these module classes out elsewhere so they can be referenced by name instead of having to instantiate them myself?

    My addons: NillaBlog | Vanoogle

  • @Lincoln ... nifty. I had to put the class in the root plugin folder. I was putting it in a folder called "modules"

    Next question, is there an easier way to contribute a sort order other than the config?

    My addons: NillaBlog | Vanoogle

  • LincLinc Vanilla's Bard (and Director of Development) Detroit Vanilla Staff
    Tagging does it manually by including the file then instantiating. I don't *think* a plugin can just grab a module by name because I think the framework only allows Applications to use modules automatically like that. However, @Tim would be the guy to know for sure.
  • @Lincoln
    I'm currently doing:
    	
    public function Base_Render_Before($Sender) {
    if (Gdn::Session()->CheckPermission("Plugins.WWDiary.View")) {
    $Sender->AddJsFile($this->GetResource('js'.DS.'common.js', FALSE, FALSE));
    $Sender->AddCssFile($this->GetResource('design'.DS.'style.css', FALSE, FALSE));
    $Sender->AddModule('SubscribeModule');
    }
    }
    and the subscribe module is in another class.subscribemodule.php along side the plugin class file.

    My addons: NillaBlog | Vanoogle

  • LincLinc Vanilla's Bard (and Director of Development) Detroit Vanilla Staff
    Things are rendered in assets in the order they were added. However, $this->Assetsis a public variable in the controller, so you could conceivable rearrange the array however you like. I'd use the BeforeRenderAsset hook.
  • LincLinc Vanilla's Bard (and Director of Development) Detroit Vanilla Staff
    @ddumont Nice! Looks like we improved module discovery and Tagging wasn't updated.
  • @Lincoln Hrmm...
    $Sender->AddModule('SubscribeModule');
    // Move the SubscribeModule to the top of the Panel
    $PanelAssets = $Sender->Assets["Panel"];
    array_unshift($PanelAssets, array_pop($PanelAssets));
    doesn't seem to be working... is that what you meant?

    My addons: NillaBlog | Vanoogle

  • @Lincoln silly me... Assets is associative.
    What controls the order?

    My addons: NillaBlog | Vanoogle

  • ddumontddumont ✭✭
    edited October 2011
    Looks like this gets me to the point where the configs are working for me:

    public function Base_Render_Before($Sender) {
    if (Gdn::Session()->CheckPermission("Plugins.WWDiary.View")) {
    $Sender->AddJsFile($this->GetResource('js'.DS.'common.js', FALSE, FALSE));
    $Sender->AddCssFile($this->GetResource('design'.DS.'style.css', FALSE, FALSE));
    $Sender->AddModule('SubscribeModule');

    // Move the SubscribeModule to the top of the Panel (See config.php)
    if ($Sender->ModuleSortContainer == "") {
    $Sender->ModuleSortContainer = "Vanilla";
    }
    }
    }
    Before, the config settings weren't doing anything.

    My addons: NillaBlog | Vanoogle

Sign In or Register to comment.