Having a 'Flags: Flagged' sorter would act very similar to 'Sticky' which would be nice. That way you can make it so that all flagged items would bump up to the top (or bottom) of a view.

CommentFileSizeAuthor
#2 flag_handler_sort_flagged-648114-2.patch1.56 KBq0rban

Comments

q0rban’s picture

After looking at the code, this is not as trivial as it sounds. There's not a flagged/unflagged column, so there would need to be some sort of SQL formula added to the orderby clause. Over my head.

// $Id$

/**
 * Handle a sort based on flagged status.
 */
class flag_handler_sort_flagged extends views_handler_sort {
  /**
   * Called to add the sort to a query.
   */
  function query() {
    $formula = $this->relationship .'.uid IS NOT NULL';
    $this->query->add_orderby(NULL, $formula, $this->options['order'], $this->table_alias . '_' . $this->field);
  }
}
q0rban’s picture

Status: Active » Needs work
StatusFileSize
new1.56 KB

This was how far I got if someone else (with more SQL knowledge than me) wants to take the ball and run with it.

Bilmar’s picture

subscribing

Bilmar’s picture

kindly bumping hoping for further work on #2 which can be reviewed by the community
thanks!

robby.smith’s picture

subscribing

YK85’s picture

+1 subscribing

JGonzalez’s picture

+1

agogo’s picture

subscribing

mooffie’s picture

mooffie’s picture

Status: Needs work » Closed (duplicate)