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.

Can't get my addon to render a js file

COOLakCOOLak New
edited May 2019 in Vanilla 2.0 - 2.8

I have an addon with the following structure:

A folder bigbrother in plugins directory

bigbrother/addon.json contains this:

{    
    "type": "addon",
    "key": "bigbrother",
    "name": "Big Brother Addon",
    "description": "Integrative functions to integrate with Bolt's Big Brother Extension",
    "version": "1.0.0",
    "mobileFriendly": true,
    "require": {
        "vanilla": ">=2.8"
    },
    "authors": [
        {
            "name": "COOLak",
            "email": "admin@mysite.com",
            "homepage": "https://www.mysite.com"
        }
    ]
}

bigbrother/class.bigbrother.php contains this:

<?php
class BigBrotherPlugin extends Gdn_Plugin {
    public function base_render_before($sender) {
        /** @var Gdn_Controller $sender */
        $sender->addJsFile('iframeResizer.contentWindow.min.js', 'plugins/bigbrother');
    }
}

The error:

The file iframeResizer.contentWindow.min.js resides in bigbrother/js directory.

The addon is enabled. And my JS isn't anywhere in the DOM. What's the issue?

Comments

  • R_JR_J Admin

    It might be the same problem as mentioned in another discussion: your plugin file should to be named either "class.bigbrother.plugin.php" or "BigBrotherPlugin.php"

  • COOLakCOOLak New
    edited May 2019

    @R_J

    Sorry, I made a typo, it already was named class.bigbrother.plugin.php. Anyway, everything started working after I emptied the cache folder.

  • charrondevcharrondev Vanilla Staff
    edited May 2019

    It's worth noting that we cache the plugin file location and addon.json contents in the cache directory which is the reason why clearing that folder fixed it.

    Realistically you need to clear the cache anytime

    • Anytime you add a new addon.
    • Anytime you update Vanilla.
    • Anytime a class in an addon moves (easiest to just do it every time you update an addon, or whenever works best during development).
    • Anytime an addon.json file changes.
    • Anytime an addon changes it's API definitions.
    • Anytime an addon changes localization strings.


Sign In or Register to comment.