Skip Navigation

[Résolu] Front end drag & drop items in view

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 2 réponses, has 2 voix.

Last updated by Stephen Vaughan Il y a 3 années et 5 mois.

Assigned support staff: Christian Cox.

Auteur
Publications
#636554

Hi,

I have had contact from a potential client through my Toolset Contractor portal. They are looking to have views on the front end that can be sortable with drag & drop. I have looked into this and the only suggestion I can see so far is to use a third party plugin such as Advanced Post Types Order. Let me know if I am overlooking a better alternative.

One thing that you may help me clarify. The client wants the page to load with the items sorted by post IDs. When these get manually re-sorted, from what I can see, he wants the IDs to change to reflect the new sorted Order. To me that looks like an impossible proposition as these are set in stone to conform to restrictions to do with the integrity of the database. Let me know if I am wrong on this.

Just a quick heads up. This morning when I log in the Support menu only give me the option to go the Contractors page, while logged out I get the navigation to the usual support pages. And, I am not able to navigate to my contractors page either. The page doesn't exist.

#636817

Hi, changing post IDs is likely to cause major problems as you mentioned, so I can't recommend it. As far as modifying the sort order of a View from the front-end of the site, the only way I can think of uses a custom field to store an integer value, and then you can sort the View based on that custom field value. The problem is...how to manage that custom field value?

A drag-and-drop front-end interface isn't provided by Views or CRED, so I think it would require custom JavaScript. When the drop happens, you would have to trigger some custom PHP code that calculates the new positions in the list and updates all the post's custom fields to match that new value. Sounds fairly complex, and I'm afraid most of this is outside the scope of support we provide here in the forums. I can show you generally how to update a custom field value with PHP, but triggering this code and figuring out what values to use for each post would be your responsibility.

As far as what you can accomplish with Views and CRED right now in the current system, you could create a page that contains a View of your posts. In the Loop Output editor, insert a CRED form that edits the current post in the loop. Remove the post title field and all the other fields except the custom sort order field. Then you can manually manage the sort order of all the posts from this page. There is not drag and drop, but it's functional.

#636841

Hi Christian,

Thanks for clarifying all that. It's not a trivial task and I don't think I have the JS chops (yet) to do any of this in code. I will look into what the Advanced Post Types Order plugin can do. The best thing to do at this stage is for me to do a full appraisal of the plugin to see what it can do. I have sent them some enquiries about this and will say what they say.

Dare I say, if the Advanced Post Types Order plugin, is up to the job, on the front end, is there merit in Toolset devs having a poke around its inner workings to see if it could be implemented in the Views plugin as a new feature?