1 of 2
1
Best Practice: How to Rank and Reorder a Set of Entries?
Posted: 09 February 2007 08:29 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  650
Joined  05-16-2004

I’ve built a few sites that share a similar requirement, and in various situations I’ve dealt with it in several different ways.  I’m wondering if there’s a “best practice” for dealing with this situation, and I thought I’d list my tactics to see which if any are recommended.

The basic situation is, I’ll have a blog that has items, but those items are not date sensitive.  In other words, it’s a list of things, like news on a certain topic, or reviews, or journals, or just static pages.  These are things that aren’t (very) date sensitive.

My client will then want to be able to order those items in the order that makes most sense to them.  In an arbitrary way, you might say.  This is so they’ll show up on an index page in a certain order, and also so that people can go to previous and next entries.

They’ll also then want to be able to re-order those entries from time to time, adding a new one in, or shifting them around.

So, that’s the situation.  Here are some solutions I’ve come up with:

1) If dates really don’t matter, you can use the EE entry date as an arbitrary value, and tell the client to change each item’s entry date to change the order.  This works extremely well in some ways: EE’s built in sorting, and prev/next feature, works properly.  But it’s a pain in the butt to go into each entry to change the date, and the widget isn’t as easy to change as, say, a simpe pulldown menu on the main entry screen.  Plus, it’s hard to remember what exactly you need to change the date to.

2) I’ve used the “related” field type to create a pretty cool “previous”/“next” functionality.  But the problem with this is that it doesn’t let you put all the items in order without a killer query.

3) I’ve used a text field that lets the user put in an arbitrary value.  But because it’s a text field, if they enter 3 4 or 5, that sorts after 1, 11 or 120. And, it doesn’t deal with duplication, and you have to go into multiple entries to reorder anything.

4) I’ve used a pulldown that has the values 01,02,03…20,21,22,23,24,25.  Problem is, this isn’t expandable to an aribtrary number of entries.  Plus, it doesn’t stop duplication.  And, “01” just looks kind of dumb instead of “1”

5) I’ve built a custom page that runs a database query that reads and sets a field, and reranks items to remove duplicates.  So far, this seems to be the most effective way.  BUT, it doesn’t clear caches when it does this, the way editing an entry does.  And, it’s very custom and is a lot of work, which is why I’ve only done it for one client.

So, I’d really like to know how anyone else is handling making arbitrary rankings of semi-static content.

 Signature 

Fight spam better with “Defensio for EE,” a free module


Hop Studios Internet Consulting
http://www.hopstudios.com/

Profile
 
 
Posted: 10 February 2007 04:24 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Hi supersusie,

I have been looking for a solution as well and am thinking about building some kind of entry sorting module.
Unfortunately I don’t have much time these days long face

They way I see this module work is very similar to your 5th solution.

Clearing the cache can be done using the “clear_caching” function: http://expressionengine.com/docs/development/reference/functions.html
Something like this should work:

<?php
    
global $FNS;
    
$FNS->clear_caching('all');
?>

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 10 February 2007 08:22 AM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6086
Joined  08-04-2002

Would be a handy module. Think I’ve tried all the same methods as Supersusie.

Profile
 
 
Posted: 12 February 2007 06:45 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Anyone interested in testing?

Keep in mind this is a beta version!
It probably won’t destroy your website, but please do NOT use on a live website yet!

Download: Order Entries Module.

I tried to make this thing as lightweight as possible and without messing with EE’s weblog tag.
The module uses EE’s ability to order Weblog Entries by a Custom Field, and just updates that Custom Field to order the entries.
It does not use any additional queries, which I think is pretty cool!

Step 1:
Create a new Custom Field in the Field Group assigned to the Weblog who’s entries you want to re-order.
- “Field Type” should be “Text Input”
- “Field Name” should be “order_entries_module” or at least start with “order_entries_module”.
Since EE doesn’t allow multiple Custom Fields with the same name, the module will check if the name starts with “order_entries_module” and use that field to order the entries.
If you need to re-order multiple weblogs, just use names like; “order_entries_module_1” or “order_entries_module_news”.

Step 2:
Install the “Order Entries” Module

Step 3:
Select a weblog and re-order some entries (to make sure you will see some result in your template)

Step 4:
Create or modify a template and change the “orderby” parameter in the weblog tag to the _exact_ name of your new Custom Field

Example of the weblog tag:

{exp:weblog:entries weblog="default_site" orderby="order_entries_module" disable="categories|member_data|pagination|trackbacks"}

<h3>{title}</h3>
{body}

{
/exp:weblog:entries}

Step 5:
If you like you can install the additional “Order Entries” Extension, this will remove the Custom Field you created from the Entry Form.
(it uses the same language file as the module, it is not missing)

Ok, what about the name of the module? I personally think “Order Entries” is a bit boring wink

Some options:
- Order Entries Module
- Custom Order Module
- Reeorder Module ?

Feel free to send me any feedback, ideas, look at the code, suggest improvements etc.

Cheers,
Elwin

[EDIT]removed the link to the old version.

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 12 February 2007 08:31 AM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12779
Joined  04-29-2002

I’d go for Reeorder. smile

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 12 February 2007 08:40 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Thanks Sue, it does sound (look) kinda cool doesn’t it LOL

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 12 February 2007 08:55 AM   [ Ignore ]   [ # 6 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6086
Joined  08-04-2002

Yes but I’d cap the “O”...ReOrder ;-)

Profile
 
 
Posted: 12 February 2007 09:05 AM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12779
Joined  04-29-2002

REEOrder.

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 12 February 2007 10:06 AM   [ Ignore ]   [ # 8 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16189
Joined  05-15-2004

Yes, Reeorder is a winner. Both the name and the actual plugin, I mean.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 12 February 2007 04:09 PM   [ Ignore ]   [ # 9 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  650
Joined  05-16-2004

Wow!  I mean, WOW!

I can’t wait to try this out.

(Oh, I thought of another way I used to do this: a single entry that has a static amount of text fields, that can be cut and pasted into the right order.  Then either display those fields straight out, or use those fields as keys to display other entries.  Anyway, I only did things this way once.)

TTFN
Travis

 Signature 

Fight spam better with “Defensio for EE,” a free module


Hop Studios Internet Consulting
http://www.hopstudios.com/

Profile
 
 
Posted: 12 February 2007 04:22 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Ok, REEOrder it is smile

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 13 February 2007 06:04 PM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Did anyone try the module yet?

I’ll probably release it this friday, unless there are still bugs that need squashing.

I already made the following changes:
- updated the name to REEOrder
- changed it to use the ‘Section Designation Word’ instead of just ‘Weblog’

I’d really appreciate some more feedback smile

Cheers!

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 13 February 2007 07:46 PM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  650
Joined  05-16-2004

OK, here’s my testing.  First, it’s great. Awesome, in fact.  However, there are a few problems: What happens when you have dozens of entries?
* It doesn’t sort properly because of the number issue (1,10,11,12,2,3,4).
* The reranking page loads slower and slower as the number of entries increases.

Example here: http://www.guesswherevancouver.com/

Next, my suggestions:

1) I’d like to be able to choose the field arbitrarily as part of the module settings, instead of having to name the field “order_entries_module”—this would make it easier to apply to existing installations, and easier to integrate into sites that have a certain field naming scheme.

2) While the arrow interface is nice, I think a pulldown for each entry would make it easier to rerank—or even just text fields, like how the current EE CP UI* allows reordering of fields and template groups.

TTFN
Travis

* I just wanted to use three abbreviations in a row.

 Signature 

Fight spam better with “Defensio for EE,” a free module


Hop Studios Internet Consulting
http://www.hopstudios.com/

Profile
 
 
Posted: 14 February 2007 01:08 AM   [ Ignore ]   [ # 13 ]  
Research Assistant
RankRankRank
Total Posts:  417
Joined  09-09-2004

use numbers entries like this…

001

002
003

012
013

 Signature 

Web Hosting - CMS - Izrada web stranica - SEO - Marketing Hrvatska

Profile
 
 
Posted: 14 February 2007 02:34 AM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Exellent, thanks Travis!

* It doesn’t sort properly because of the number issue (1,10,11,12,2,3,4).

I had exactly 9 entries in my testpage so never ran into it yet, go figure smile
Fixed it by padding the number to 4 figures (0001, 0002, etc.) 4 should be enough.

* The reranking page loads slower and slower as the number of entries increases.

Do you mean the modules CP UI?
If the actual front-end template is slow, that cannot be caused by the module itself.
The module doesn’t add any processing to the page, it’s just the weblog tag ordering by a custom field.
I do however empty all caches when you update the order, if you use caching, the first page visit might be slower.

1) I’d like to be able to choose the field arbitrarily as part of the module settings, instead of having to name the field “order_entries_module”—this would make it easier to apply to existing installations, and easier to integrate into sites that have a certain field naming scheme.

I didn’t go that route because I was afraid people would accidentally choose the wrong field.
The module doesn’t care what data is in there, it will just overwrite it when you re-order.
I’ll look into it.

2) While the arrow interface is nice, I think a pulldown for each entry would make it easier to rerank—or even just text fields, like how the current EE CP UI* allows reordering of fields and template groups.

Hmm, interesting…

The idea behind the module is (as always) to keep it as simple as possible so our ‘the client’ can use it.
However, offering an extra ‘quick-jump-order’ pulldown next to the arrows could speed up ordering, but I really don’t like the idea of having to edit text fields.

Thanks again for the feedback!
Elwin

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 14 February 2007 02:52 AM   [ Ignore ]   [ # 15 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  650
Joined  05-16-2004

I think the code is fine and efficient, and I have no problem with the front end of the site displaying in the right order quickly.

I’m just saying that the adminstrative reranking UI, when faced with, say, 800 entries, bogs down because there’s so much to load on the page.  Pagination may be something to address in version 2.0, perhaps.

Last possible suggestion: Assume every existing entry is in proper order.  Then I add a new entry.  That entry, which has a blank in the ordering field, appears at the bottom of the list.  But new entries, I often want them at the TOP of the list, because they’re new, and I’m faced with dozens of clicks to make that happen.  Do you think you ought to make that the default, or at least a setting (new items on top/bottom)?

TTFN
Travis

 Signature 

Fight spam better with “Defensio for EE,” a free module


Hop Studios Internet Consulting
http://www.hopstudios.com/

Profile
 
 
Posted: 14 February 2007 03:15 AM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

While re-ordering 800 entries would not be very efficient, I can see people wanting to show a selection of those 800.
Your pulldown idea might make this easier, but pagination is on the list.

I actually tested with new entries being on top, but decided to stick to the order of EE’s weblog tag, which is descending.
The only option here is adding a preference to sort the list ASC or DESC, which would affect where new entries end up as well.
(when setting the REEOrder pref setting to ASC you’ll have to do the same in your weblog tag)

Very useful feedback!

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 14 February 2007 03:31 PM   [ Ignore ]   [ # 17 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Ok, here is a new version for you to try.

Download: REEOrder Module 0.9.

Please trow away the “Order Entries” Module and Extension.

New in this version:
- name change
- fixed the number issue (1,10,11,2, etc)
- added a dropdown menu for easier and faster re-ordering.
- you can now select the Custom Field as a preference, per weblog.
- changed the default sort order to ascending (ASC), so new entries will be added at the TOP of the list

Notes:
- you need to be a Super Admin to edit preferences! (you won’t even see the link when you’re not)
- because I changed the default sort order to ASC you need to add sort=“asc” to your weblog tag as well.
- the sort order ASC or DESC isn’t a preference setting yet, but I will add it soon.

Thanks for testing people smile

Cheers,
Elwin

EDIT: removed download link

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 15 February 2007 06:57 AM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Forget about 0.9, here is version 1.0.

Download: REEOrder Module 1.0

New in 1.0
- added ability to set the Sort Order (ASC, DESC) per weblog

Cheers,
Elwin

EDIT: I will officially release the module this weekend in a new thread.

 Signature 

Member of the EE Pro Network

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66467 Total Logged-in Users: 35
Total Topics: 84862 Total Anonymous Users: 15
Total Replies: 455343 Total Guests: 187
Total Posts: 540205    
Members ( View Memberlist )