Jump to content
Sign in to follow this  
turmeric

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

Recommended Posts

Posted (edited)

Hi,

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:

https://github.com/cubecart/v6/blob/1c15992f4d8306584a26cf7bb8dc8c56d02480b1/classes/gui.class.php#L174

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.

Thanks,

 

Edited by turmeric

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites
Posted (edited)

This is pretty useful info, thanks @bsmither. It would be useful if there were more dev docs for CubeCart, like a mini WordPress codex.

Edited by veyroo

Share this post


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.

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.

Sign in to follow this  

×
×
  • Create New...