We have the intranet_js plugin hook to allow adding javascript to all intranet pages.. it would be great to have the specific page the hook is called from get passed so we can optionally run code to generate and return the JS instead of returning it for all pages.
Created attachment 183380 [details] [review] Bug 40095: Add context to intranet_js plugin hook The get_plugins_intranet_js method now passes the current script name (controller) to plugins via a 'page' parameter, allowing plugins to determine which page/controller is being displayed. This will allow plugin authors to only return JS that's relevant to the current page when they wish to do so. Test plan: 1. Create a plugin with an intranet_js method that logs the received parameters 2. Navigate to different pages in the staff interface 3. Verify that the plugin receives the page parameter containing the script name 4. Confirm that the script name reflects the actual controller (e.g., '/cgi-bin/koha/admin/admin-home.pl' when on the admin home page) 5. Run the test: prove t/db_dependent/Koha/Template/Plugin/KohaPlugins.t 6. Verify that the new test passes, confirming plugins receive the page parameter
Created attachment 183411 [details] [review] Bug 40095: Add context to intranet_js plugin hook The get_plugins_intranet_js method now passes the current script name (controller) to plugins via a 'page' parameter, allowing plugins to determine which page/controller is being displayed. This will allow plugin authors to only return JS that's relevant to the current page when they wish to do so. Test plan: 1. Create a plugin with an intranet_js method that logs the received parameters 2. Navigate to different pages in the staff interface 3. Verify that the plugin receives the page parameter containing the script name 4. Confirm that the script name reflects the actual controller (e.g., '/cgi-bin/koha/admin/admin-home.pl' when on the admin home page) 5. Run the test: prove t/db_dependent/Koha/Template/Plugin/KohaPlugins.t 6. Verify that the new test passes, confirming plugins receive the page parameter Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>