Order Entries
This is an open discussion with 224 replies, filed under Extensions.
Search
Order Entries provides drag and drop functionality for entries in the Publish table.
Features
- Adds a field, "Entry Order" (number field) to add to a section
- When viewing the Publish table, if the table is ordered by this field, allows a user to drag entry rows
- Saves order via AJAX with instant feedback to the UI
- Auto-increments the Entry Order field for new entries
Limitations
- Working across paging was problematic so I simplified. When dragging is enabled (when the table is ordered by the Entry Order field) paging is removed entirely, so entries from the bottom can be dragged to the top in one page view.
- Functionality is enabled only when the Entry Order field is the table sort field, and ordered ascending. I didn't have the time to add support for descending, but I imagine this would be a simple ammendment.
Requirements
Version 1.2+ of this extension requires Symphony 2.0.2.
Download
This is great Nick, I can see lots of potential uses.
Nick, you are my hero, been waiting for this for a while, cheers!
Very nice. Kudos.
Thank you so much, Nick! This is a killer extension!
@Nick: Doesn't work if Symphony is not installed in the root, but in a subdirectory. I think I found the reason in line 14 of order.js
:
var save = new Request("/extensions/order_entries/assets/save.php", function(request) {
I tried a relative URL -- bingo!
var save = new Request("../../../extensions/order_entries/assets/save.php", function(request) {
I fixed this problem when embedding the JS itself, but forgot about the path in the JS file. Thanks for the fix Michael — I have updated with v0.3.
The fix is nothing. Your extension is "wow"! Thank you, Nick!
In the past I often wished to have an extension like this. Simply ordering articles by date or by IDs is not Symphony-like, I said to myself... Your extension brings a higher degree of freedom to content design and content management. Cool.
That's awesome! Thanks, Nick.
The only thing I might suggest is changing the cursor to a move icon on hover to indicate that the rows are draggable, but that's pretty minor. Also, I can confirm it's now working for installs in subdirectories.
@Nick: Suddenly it stopped working. I am not sure why. All I noticed at first glance it that the sym_fields_order_entries
table is completely empty. Shouldn't it have some content?
It's again saving that fails. All the UI stuff looks precisely like it did before.
I locked down the problem.
Some days ago I had a long discussion with Marcin on the bug tracker. I decided to change the login procedure to the latest development version (installing class.cookie.php
and class.session.php
from github).
Guess what? The follwing line in the extension's save.php
file will cause the script to return:
if(!$symphony->isLoggedIn()) return;
So at the moment it seems that the public function isLoggedIn
in /symphony/lib/core/class.administration.php
is broken with the new login procedure. If I comment out this line, everything will work again. So the problem is not in the extension, but in the dev code on Github. I will think about that and do some more research.
I found that the isLoggedIn
function is indeed working in the dev code. I am using it in events I created, and everything's fine there. So the problem might be that the Order Entries field extension's php script save.php
does not have access to this function if you use the dev version of class.cookie.php
.
I double checked that reverting the class.cookie.php
file from the dev version to the 2.0 version solves the problem.
So what is the right way to go from here? Any ideas?
Thanks for doing the digging michael-e. I'm not sure of the way to proceed. For the time being you could leave the line commented out, if you're comfortable with the script being insecure. I'm not clued up enough in the ways of the Symphony class structure to figure out an alternative function call...
nickdunn, thanks to michael-e report there is a patch available now, which should fix this problem :).
Nick, Marcin (aka ahwayakchih) helped me to figure this out. I described the various cases on the bug tracker.
Short version (two main cases):
- You are using Symphony 2.0. In this case, your extension will work fine.
- You are using the dev version of Symphony. There have been many changes. You need to update the extension's
save.php
code.
Here is the code that works for me in a Symphony development version installation:
<?php require_once('../../../manifest/config.php'); require_once(CORE . '/class.administration.php'); $Admin = Administration::instance(); if(!$Admin->isLoggedIn()) return; $field_id = $_REQUEST["field"]; $items = $_REQUEST['items']; if(!is_array($items) || empty($items)) return; foreach($items as $id => $position) { $Admin->Database->query("UPDATE sym_entries_data_$field_id SET value = '$position' WHERE entry_id='$id'"); }
Thanks Michael. I'd rather not tie this directly to the latest build, so I wonder whether there is a way I can check in the code. Perhaps seeing if the newer method exists first, and choosing which to call?
This way it would work both with v2.0 and 2.x. Any thoughts?
nickdunn, You could try to call method_exists() on instance() function. AFAIK it was added after 2.0, so it should work.
edit: unfortunately it doesn't work well on static functions on PHP 5.0 (Symphony requires 5.1 IIRC). You could also try to wrap it with try {} catch {}, like this:
try { $Admin = Administration::instance(); } catch (Exception $e) { $Admin = new Administration(); } finally { // Die here? }
@nichdunn: Keep it simple. Anyone using the Github code of Symphony may apply the patch manually. Your extension should definitely work with the official Symphony release. Once Symphony 2.1 is released, you might update the code, of course.
You might add the requirements (for now: S 2.0 official release) to your first post!
Thanks for the clarification mate. I find it tricky to keep up with the commits to the Symphony core so it's useful to have it explained. Requirements added.
Create an account or sign in to comment.
A new Extension, “Order Entries” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.