I am developing a website on laravel, in which each news has its own slider (from 3 to 7 slides, that is, pictures). And nothing difficult, but you need to do that in order to create news, you could specify the order of images in the slider, and when news changes, replace existing images in the slider and change slides (images) in places.

On the Internet, there are many examples of multi-loading images, but that would be able to indicate the position of the image - I did not find anything like it.

I tried to create news using jquery sortable to do that bi-input with images swapped. This, as it were, solves the problem of indicating a position. But to do this with news editing, when you need to change positions and, at the same time, change / delete / add images - this is already problematic (probably even a crutch), if at all possible.

Maybe someone faced this task? I will be glad to any help and advice in the concept and solution of this problem. In particular, the structure of the database is of interest: is it better to save pictures in the news table or create a separate table with slides that will be tied to the news id?

Sorry for the blur and lots of letters.

Closed due to the fact that the question is too common for participants 0xdb , Enikeyschik , Jarvis_J , Kosta B. , rdorn Dec 2 '18 at 1:25 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    The task is atypical, not the easiest and you have to make your custom solution.

    A typical news admin on any medium engine usually contains an html editing field - sit on the tags with your hands or paste them using ready-made buttons.

    In this case, all the sliders are written in the code by the hands and, accordingly, if you need to swap the order of the slides, the editor manually rearranges the rows. It is also good if the slider has a simple structure, when you can safely rearrange the blocks in some places. No, well, and cho - let the content editor work out his bread, right? This direction is number one; it does not suit you by definition.

    The second option. When you have a picture for each news item, these pictures are stored separately and additional information is saved for each picture:

    • what news is the foreign key to the news table
    • news slider number (zero if not included in any slider) - int
    • sequence number inside the slider - int

    In this case, in the text of the news they agree on a special markup, which will be replaced with the slider output when displaying news. Well, from the bald, for example: <!-- slider:1 --> will be replaced with the output of slider 1, all the pictures included in this slider will be selected and the order in them will be as specified in the sort order.

    Consider this option as a baseline, from which you will build on your decision.

    The third option is to select a separate entity and name it slider, while in your news editor a new button will be added to insert a slider, but the slider will be edited separately from the news - and there you can only insert pictures and specify their order. The rest of the option is similar to option 2.

    In short, I see these two directions, then everything depends on how fully the programmer’s resources allow you to solve this problem.

    And further. Insert slide sequence numbers by default in the code after 10: 10, 20, 30 - then you can quickly insert several new pictures manually, especially without bothering with the up / down buttons - and giving the user the opportunity to manually enter the digits.