<p>I'm not sure if this will help anyone in the future, but I was able to get it working. Basically, I needed to have the plugin folder <code>psmw</code> both in <code>plugins/businesslogic/vendor</code> and at the <code>root</code> of my project. The PHP was executed within the plugin, while the CSS and JS was referenced from the <code>root</code>, since you can't point to assets within the plugin folder from a Craft template. May not be the sexiest method, but it works.</p>

CC BY-SA 3.0
2018-01-26T22:49:30.667Z
Of course you can https://craftcms.com/docs/plugins/resources `includeJsResource('pluginName/path/to/file.js')` will point to a plugins js file. So you just need to move the files to your Ressource folder. There are also ways to reference them in your plugins main folder but that requires a little bit more knowledge
Robin Schambach
CC BY-SA 3.0
2018-01-28T16:41:52.903Z
Thanks, didn't know about that, I'll have a look!
Bryce
CC BY-SA 3.0
2018-01-26T22:27:37.300Z
2018-01-26T22:27:37.300Z
Bryce
<p>Sounds like you haven't loaded jQuery on that page. You'll need to make sure that jQuery is loaded <em>before</em> your <code>{{ craft.businessLogic.shortcode }}</code> tag.</p>

CC BY-SA 3.0
2018-01-26T17:27:38.957Z
Loading my version of jQuery (3.3.1) in the head doesn't erase the error, but loading the version in the documentation (2.0.3) does. However, there's no change, the plugin still doesn't work.
Bryce
CC BY-SA 3.0
2018-01-26T20:30:50.917Z
Maybe you could explain us what does not work? Do you receive a new error? Is there nothing at all in your console? Maybe there is a red entry in your network tab?
Robin Schambach
CC BY-SA 3.0
2018-01-26T04:15:42.363Z
2018-01-26T04:15:42.363Z
Lindsey D
<p>Hokay, this is a big one. Thanks in advance for anyone that has a look:</p>

<p>I’m trying to get <a href="https://codecanyon.net/item/premium-stock-market-widgets-js-php/19714578" rel="nofollow noreferrer">this</a> widget working on a Craft site.</p>

<p>The install documentation is pretty simple, I've hosted it here: <a href="http://brycekirk.com/documentation/" rel="nofollow noreferrer">http://brycekirk.com/documentation/</a></p>

<p>I've also installed <a href="https://github.com/lindseydiloreto/craft-businesslogic" rel="nofollow noreferrer">Business Logic</a>. Within that plugin, I've created a folder called <code>vendor</code> and and moved the <code>psmw</code> folder into it. </p>

<p>I've then initialized it in <code>BusinessLogicPlugin.php</code>:</p>

<pre><code>public function init() {
    require_once 'vendor/psmw/init.php';
}
</code></pre>

<p>and added into <code>/variables/BusinessLogicVariable.php</code>, I've added the path to the shortcode functions, and a test one:</p>

<pre><code>public function shortcode($optional = null)
{
    require_once(CRAFT_PLUGINS_PATH.'businesslogic/vendor/psmw/shortcode.php');
    shortcode(['type' =&gt; 'spark', 'symbol' =&gt; 'AAPL', 'template' =&gt; 'line', 'color' =&gt; 'blue']);
}
</code></pre>

<p>And then called it in my template with <code>{{ craft.businessLogic.shortcode }}</code>. It's generating HTML and JS, but not displaying the ticker, and I'm getting a <code>jQuery is not defined</code> error. </p>

<p>I'm sure there's something wrong with the logic behind how I'm loading in the plugin and its assets, I just can't figure out what it is. Any gesture in the right direction would be much appreciated! I can provide more info if needed.</p>

<plugins><php>
Widget initialized in Business Logic plugin not loading
# Widget initialized in Business Logic plugin not loading

(Asked by: username_0 on 2018-01-26)

Hokay, this is a big one. Thanks in advance for anyone that has a look:
I’m trying to get this widget working on a Craft site.
The install documentation is pretty simple, I've hosted it here: http://brycekirk.com/documentation/
I've also installed Business Logic. Within that plugin, I've created a folder called vendor and and moved the psmw folder into it. 
I've then initialized it in BusinessLogicPlugin.php:
public function init() {
    require_once 'vendor/psmw/init.php';
}

and added into /variables/BusinessLogicVariable.php, I've added the path to the shortcode functions, and a test one:
public function shortcode($optional = null)
{
    require_once(CRAFT_PLUGINS_PATH.'businesslogic/vendor/psmw/shortcode.php');
    shortcode(['type' => 'spark', 'symbol' => 'AAPL', 'template' => 'line', 'color' => 'blue']);
}

And then called it in my template with {{ craft.businessLogic.shortcode }}. It's generating HTML and JS, but not displaying the ticker, and I'm getting a jQuery is not defined error. 
I'm sure there's something wrong with the logic behind how I'm loading in the plugin and its assets, I just can't figure out what it is. Any gesture in the right direction would be much appreciated! I can provide more info if needed.

**Tags:** plugins, php


---

## 2 answers

### Answer by username_0 on 2018-01-26. Score: 1 | Accepted answer

I'm not sure if this will help anyone in the future, but I was able to get it working. Basically, I needed to have the plugin folder `psmw` both in `plugins/businesslogic/vendor` and at the `root` of my project. The PHP was executed within the plugin, while the CSS and JS was referenced from the `root`, since you can't point to assets within the plugin folder from a Craft template. May not be the sexiest method, but it works.

> **Comments:**
> **username_1**: Of course you can https://craftcms.com/docs/plugins/resources `includeJsResource('pluginName/path/to/file.js')` will point to a plugins js file. So you just need to move the files to your Ressource folder. There are also ways to reference them in your plugins main folder but that requires a little bit more knowledge  
> **username_0**: Thanks, didn't know about that, I'll have a look!  

---

### Answer by username_2 on 2018-01-26. Score: 1

Sounds like you haven't loaded jQuery on that page. You'll need to make sure that jQuery is loaded *before* your `{{ craft.businessLogic.shortcode }}` tag.

> **Comments:**
> **username_0**: Loading my version of jQuery (3.3.1) in the head doesn't erase the error, but loading the version in the documentation (2.0.3) does. However, there's no change, the plugin still doesn't work.  
> **username_1**: Maybe you could explain us what does not work? Do you receive a new error? Is there nothing at all in your console? Maybe there is a red entry in your network tab?  

---

