- Issue created by @shweta__sharma
- Assigned to Shreya_98
- Issue was unassigned.
- Assigned to anish.ir
Hi,
I encountered an issue where the hamburger menu in the theme was not working correctly. After debugging, I discovered that the JavaScript files required for the functionality were not being loaded due to incorrect paths. Specifically, the plugin_path variable in the test.js file was pointing to the custom folder instead of the contrib folder. So, whenever we install the site it is installed in the '/themes/contrib/' rather than '/themes/custom/'.
Hereโs a summary of the issue and resolution:
Issue:
- The JavaScript files, including bootstrap.min.js and jquery.flot.min.js, were not loading.
- The browser console showed MIME type errors and 404 errors for the JS files.
- The incorrect path in the plugin_path variable was causing the system to look for files in /themes/custom/smarty_admin/ instead of /themes/contrib/smarty_admin/.
Resolution:
- I updated the plugin_path variable in the test.js file to:
var plugin_path = '/themes/contrib/smarty_admin/assets/plugins/'
- After this change, the JS files were correctly loaded, and the hamburger menu started working as expected.
Recommendation:
Please update the test.js file in the theme to ensure the correct path (contrib instead of custom) is used for plugin_path.
Alternatively, consider making the path dynamic to avoid hard-coding issues in the future.Currently, I am raising the MR with the changes and attaching the screenshots along with the error Let me know if you need any further details or assistance.
Thanks!- Merge request !5Issue #3391500: Changed the plugin_path to contrib. โ (Merged) created by anish.ir
Hi,
As mentioned earlier, the issue with the hamburger menu not working was due to incorrect paths in the plugin_path variable in test.js, which pointed to
/themes/custom/
instead of/themes/contrib/
.I resolved this by dynamically setting the theme path in drupalSettings using the following approach:
$theme_path = \Drupal::service('extension.list.theme')->getPath(\Drupal::theme()->getActiveTheme()->getName()); $variables['#attached']['drupalSettings']['smartyAdmin'] = [ 'themePath' => '/' . $theme_path, ];
Updated test.js to:
var plugin_path = drupalSettings.smartyAdmin.themePath + '/assets/plugins/';
This ensures the correct path is used dynamically, avoiding hardcoding issues. Now, whatever the path of the theme be, the scripts will load dynamically.
I've raised an MR with the changes.Thanks!
- ๐ฎ๐ณIndia hetal.solanki
@anish.ir
I have review MR!5. It's working for me.
Moving to RTBC.
Thank you!!
-
jaydeep_patel โ
committed 35d026c2 on 8.x-1.x authored by
anish.ir โ
Issue #3391500: Changed the plugin_path to contrib.
-
jaydeep_patel โ
committed 35d026c2 on 8.x-1.x authored by
anish.ir โ
- ๐ฎ๐ณIndia jaydeep_patel Ahmedabad
Merged.
Thank you @shweta__sharma, @anish.ir and @hetal.solanki for your contribution. Automatically closed - issue fixed for 2 weeks with no activity.