Jump to content

Extension selling help


bondimedical

Recommended Posts

With a hook.

In the GUI __construct() function, there are hooks for:
1) class.gui.head_js
2) class.gui.body_js
3) class.gui.javascripts

These statements will be in an appropriately named hook file(s) in the plugin's /hooks/ folder:

1. $head_js[] = either <script src="wherever"></script> tags or actual <script>javascript</script>.

2. $body_js[] = either <script src="wherever"></script> tags or actual <script>javascript</script>.

3. $js[] = must be the relative path to the file containing the javascript, such as:
   $js[] = "modules/plugins/my_plugin/js/script1.js";

The Foundation template has:

Near the top:
{foreach from=$HEAD_JS item=js}{$js}{/foreach}

Near the bottom:
{foreach from=$BODY_JS item=js}{$js}{/foreach}
{foreach from=$JS_SCRIPTS key=k item=script}
<script src="{$STORE_URL}/{$script|replace:'\\':'/'}" type="text/javascript"></script>
{/foreach}

 

Link to comment
Share on other sites

Just to add a bit more info. The hooks for:

1) class.gui.head_js
2) class.gui.body_js
3) class.gui.javascripts

are processed when Cubecart first starts up.

Therefore, if you are wanting to construct the javascript with dynamic data, you will need to assemble it in the hook file. For example:

$body_js[] = 'var foo = "'
  . $some_developed_aspect_about_the_product_being_viewed
  . '";';

That won't work because nothing about the product has been assembled at this point.

I had to use the class.gui.display hook (last hook executed), fetch the array BODY_JS template variable back from Smarty, add the plugin's javascript to that array, then assign it back to BODY_JS.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...