The objective is to create a WordPress Gutenberg slider block using Swiper.js that meets the following requirements:
Container Block: Acts as a container where multiple elements can be added.
Automatic Detection: Automatically detects the number of elements and generates corresponding "dots" indicators.
Special Handling for Specific Blocks: Recognizes "post listing" and "tour listing" blocks and applies the swiper-slide class to their direct children.
Utility Class Powered:
By default, the slider won't display "dots" or "arrows".
"Dots" and "arrows" appear only when corresponding CSS classes are added.
Use of Swiper JS: we should use Swiper JS with external calls.
Customizable Slides Per View and Slides Per Group: Users can specify the number of slides to display at once and the number of slides to swipe when clicking an arrow, via sidebar settings.
Issues Encountered
Classes Not Applied: The swiper-slide class is not being automatically added to inner blocks.
All Slides in Same View: Despite setting slidesPerView to 1, all slides appear in the same view.
Navigation Arrows: Arrows appear outside the slider and are not correctly positioned.
Swiper Initialization: Swiper is not correctly initialized, leading to the incorrect behavior of the slider.
Often get the error useInnerBlocksProps is not defined, and can not insert the block on page...
Summary of Actions Taken
Remote-x-blocks.php
php
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Despite multiple attempts to apply the swiper-slide class to inner blocks and initialize Swiper correctly, the slider block did not work as intended. The primary issues were:
Classes Not Applied: The swiper-slide class was not added to inner blocks.
All Slides in Same View: All slides appeared in the same view despite setting slidesPerView to 1.
Navigation Arrows: Arrows were not correctly positioned within the slider.
Swiper Initialization: Swiper did not initialize correctly with the provided settings
=> Please provide revised working codes to make it work
Thank you for providing the detailed explanation of the issues you've encountered while implementing the slider block with Swiper.js. I'll provide you with revised code that should address the problems you mentioned.