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.



Link to comment
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).

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...