Help get this topic noticed by sharing it on Twitter, Facebook, or email.
I’m hopeful

Re-ordering favourites?

Is it possible to reorder the favourites somehow? I can easily think of a way of doing it with jQuery, but wondered if there might be a solution if users have javascript turned off?

Thanks!
1 person has
this question
+1
Reply
  • Hi Tim,

    there are currently no EE tags for this - but it is certainly a good feature request. How would you see this working - a tag for moving a specific favourite up and one for moving a favourite down?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • I was thinking just number text input fields but up/down would be good.

    I'd most probably end up wanting to use jQueryUI Sortable - so would be great if there was a way to hook into that - just trying to work this out with the current code!
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • I’m happy
    Mostly to remind myself but might be handy for someone - these are the tweaks I made to get things working with jQuery sortable:

    Created callback to deal with the changed state:

    function newOrder() {
    var list = new cookieFavs();
    var newitems = list.items();
    newitems = new Array();
    $('#custom_trail_venues li').each(function(index) {
    var idarr = $(this).attr('id').split('-');
    var entry_id = idarr[1];
    newitems.push(entry_id);
    });
    list.reset(newitems);
    }

    $( "#custom_trail_venues" ).sortable({
    axis: "y",
    cursor: "move",
    update: function() { newOrder(); }
    });
    $( "#custom_trail_venues" ).disableSelection();


    Then added a 'reset' method to cookieFavs (and changed statements for 'null' into new Array() as Firebug had a problem with that )


    var cookieFavs = function() {
    var cookieName = "exp_cookie_favourites";
    var cookie = $.cookie(cookieName);
    var items = cookie ? cookie.split(/,/) : new Array();

    return {
    "add": function(val) {
    items.push(val);
    $.cookie(cookieName, items.join(','), {expires: 730, path: '/'});
    },
    "remove": function(val) {
    items = $.grep(items, function(value) {
    return value != val;
    });
    $.cookie(cookieName, items.join(','), {expires: 730, path: '/'});
    },
    "clear": function() {
    items = new Array();
    $.cookie(cookieName, items, {expires: 730, path: '/'});
    },
    "items": function() {
    return items;
    },
    "reset":function(newitems){
    $.cookie(cookieName, newitems.join(','), {expires: 730, path: '/'});
    }
    }
    }

    Then what finally tripped me up for ages was actually just to do with the Channel Module - had to make sure I set the channel order to:


    fixed_order="{favourites_entry_ids}"
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Amazing stuff, Tim! :-) I've added EE tags for sorting on my todo for CookieFav so non-js fallback will be available in the next release.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated