-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEATURE: Logic hook that will allow adding custom javascript code in header without modifying template #7158
Comments
I know this is an old post, but in case anyone else comes across this, you absolutely can add JS to head of editview without modifying the template. Here's an example ( I have a custom module billable hours where I want to calculate the total charge based on hours x hourly rate). Also, this is an application hook. You have to put it in custom/modules/logic_hooks.php `$hook_version = 1; $hook_array['after_ui_frame'] = array(); Then here's my PHP file: class CustomJS { EOT; |
Same way for adding custom CSS to the |
Yes you could. I haven't tried it but my guess is yes.
I've limited the function to only my custom module and edit view. Bit you could probably limit it to whatever you like.
…On Sun, Aug 13, 2023, 10:45 p.m. Chris Coleman ***@***.***> wrote:
Same way for adding custom CSS to the head of the page?
—
Reply to this email directly, view it on GitHub
<#7158 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHBNDZ5K6K6YTC7QHQ234R3XVGGM7ANCNFSM4HEGAQDQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Actually, on further investigation it places the script close to the beginning of the body not in the . However, the functionality works of adding in JS to the page without having to edit the template. For CSS this would be a good place to put it too because it would override CSS in the head because it loads later. You just have to get creative about how you limit where it fires because the hook will fire on every page and you need limit the function to only output the JS or CSS on the pages you want. |
@pstevens71 Thanks. Tried it here. You're right. It works well. |
Issue
Add logic hoot that will allow inserting custom javascript (or other) code in page header.
Currently, after_ui_frame, after_ui_footer and server_round_trip logic hooks add code towarde the end of the page and after_entry_point will add code on the top of the page, before any other processing.
For example, Google Analytis code should be placed at the top of the head tag and that requires modifying theme template (themes//tpls/_head.tpl)
The text was updated successfully, but these errors were encountered: