A
A
Alexander2020-01-13 13:37:58
JavaScript
Alexander, 2020-01-13 13:37:58

Which page builder to choose for Wopdress?

Hello, please recommend a good page builder, thanks in advance.
There is a ready-made layout that I want to integrate into WP, I used to use purely ACF and Register Post type, but this is not the best option, since the user does not have the ability to add his own blocks to the page, but only edit the existing ones.
5e1c484c77864167641734.png
5e1c485ad53e9687071295.png

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
dom1n1k, 2019-03-27
@dom1n1k

There is a lot of room for improvement in the code shown. But your goals and scope of the task are not clear.
Offhand:
0. Why is some library not used? Not necessarily a big one like Slick, there are also easier options.
1. Think about what will happen if there are more than one sliders on the page?
2. Write jQuery-like addClass/removeClass functions (if you don't want to use classList). Working with "active" (with a space) is dangerous.
3. Transfer class names to constants. And use BEM ("item" can be found anywhere).
4. Can the number of slides and dots vary? Judging by the code - no, but why then two cycles?
5. Setting display: "block" is also dangerous, because there could theoretically be something else (flex for example).
6. The name of the currentSlide function is bad - it's not at all clear what it does. Getter or setter?

H
hzzzzl, 2019-03-27
@hzzzzl

well, you can check that the index does not go beyond the boundaries of the array like this, and simply send 1 or -1 to showSlides, such as the next slide or the previous one ... and yes, everything works the same and is well read

/* Устанавливает текущий слайд */
function currentSlide() {
    showSlides();
}

/* Функция увеличивает индекс на 1, показывает следующй слайд*/
function plusSlide() {
    showSlides(+1);
}

/* Функция уменьшяет индекс на 1, показывает предыдущий слайд*/
function minusSlide() {
    showSlides(-1);  
}

/* Основная функция слайдера */
function showSlides(n = 0) {
    // ставим следующий слайд вот так
    slideIndex = (slideIndex + n) % slides.length < 0 
      ? slides.length - 1 
      : (slideIndex + n) % slides.length


    ....

V
Victor Golovko, 2019-03-27
@siptik

Why do you need optimization? Also, the task is not clear on the slider.
If you need to make a second slider on the page, then the code is no longer working.

Y
yarovikov, 2020-01-13
@axrising

What? With acf, Gutenberg blocks are great. And then there is flexible_content, which is a hundred years old at lunchtime.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question