The drag and drop design modules in BeikeShop's default theme rely on JavaScript code that's not explicitly included in the provided files. However, we can infer some of the mechanisms based on the provided context. The missing piece is likely a JavaScript library (possibly something like SortableJS or a custom implementation) that handles the actual drag and drop functionality.
Here's a breakdown of how it likely works and why your "theme1" might not have this functionality:
-
Module Rendering: PHP components (Beike\Admin\View\DesignBuilders\*) render the modules with specific data, including a code, sort, name, and icon. This data is used to display the modules in the design builder interface within the admin panel. The rendered HTML likely includes specific classes or data attributes that the JavaScript library uses to target the draggable elements.
-
Module Tool: The _module_tool.blade.php partial provides the visual controls for manipulating modules (move up, move down, delete, edit). These controls likely trigger JavaScript functions to perform the corresponding actions, including updating the sort order. Crucially, this partial is only included when $design is true, suggesting a variable passed to the view to control when the design tools are visible (likely only in the admin's design builder view).
-
JavaScript Library (Missing): A JavaScript library is responsible for handling the drag and drop events. This library would:
- Make the module elements draggable.
- Detect when a module is dropped in a new position.
- Update the underlying data (likely via AJAX calls to the backend) to reflect the new module order. This probably involves updating the
sort value for each module.
-
Backend Updates: The backend (not shown in the provided code) would receive the updated sort order from the JavaScript and persist it to the database. This ensures that the layout is preserved when the page is rendered again.
Why "theme1" doesn't work:
Your custom "theme1" likely doesn't have the necessary JavaScript library included, or the required HTML structure and data attributes in the rendered modules. You'll need to:
-
Include the JavaScript Library: Copy the JavaScript library used in the default theme to your "theme1" assets. Make sure this library is included in your theme's layout file (similar to how jQuery, Bootstrap, and other libraries are included in themes/default/layout/master.blade.php).
-
Check HTML Structure: Ensure that the modules rendered in "theme1" have the same HTML structure, classes, and data attributes as the default theme. The JavaScript library relies on these to function correctly.
-
Verify Backend Integration: Double-check that your "theme1" integrates correctly with the backend routes and controllers that handle updating the module order. If you've modified any backend code related to design modules, ensure it's compatible with the frontend drag and drop functionality.
-
Debug: If you're still having issues, use your browser's developer tools (especially the console and network tabs) to debug the JavaScript and AJAX requests. This will help you identify any errors or inconsistencies.
By addressing these points, you should be able to get the drag and drop design module functionality working in your "theme1".