Jump to content

Cannot get class.gui.body_js.php hook to output js in footer?

Recommended Posts


I am hooking into class.gui.body_js.php in a test plugin, my hook file has:

$body_js[] = "<script>alert('test')</script>";

That script will not appear in the footer scripts.

I have tried outputting the data where CubeCart is using the class.gui.body_js.php hook to see if my data is getting through:


I have var dumped $body_js around that code and it contains my data. I think I am doing everything required, am I missing something?

I am running a freshly downloaded CCv6 today with the default foundation theme, no other edits.



Edited by turmeric
Link to post
Share on other sites

Welcome turmeric! Glad to see you made it to the forums.

The CubeCart GUI variable $body_js is assigned to Smarty's BODY_JS variable. The $BODY_JS variable is then looped through (see skin template element.js_foot.php), putting each array element into a Smarty template variable $js_foot. The Smarty template variable $js_foot is then fed through a combine function that fetches all the script files into one single file.

Note that the Smarty template variable $js_foot requires path/filenames to the individual javascripts. If the array element is not a path/filename, or if the actual file cannot be found, the array element is ignored.

The GUI $body_js variable is limited to javascript path/filename.js files.

Please consider adding actual <script> code using the class.gui.body_js_top hook (see the skin template main.php, just after the <body> tag).

Edited by bsmither
Link to post
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.

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...