Exposing the flaggings table

mooffie - February 9, 2009 - 11:25
Project:Flag
Version:6.x-1.x-dev
Component:Views integration
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Issue tags:flag 1.2
Description

One thing the Views support lacks is "real" exposure of the 'flag_content' table. This table stores flaggings. Currently, because of a "let's hide the frightening word 'flaggings' so users feel comfortable" philosophy, this table doesn't get the treat it deserves. Exposing this table is 90% of implementing the "Ability to flag flaggings" feature, but it also enables most trivial things like filtering by flags

#1

mooffie - February 9, 2009 - 11:28

I'm attaching a schema of how this can be done. This is a rip off of once-functional old patch I had laying around.

AttachmentSize
flag.views_.txt 3.68 KB

#2

mooffie - February 9, 2009 - 12:04

  // Advertise this table as a possible base table
  $data['flag_flagging']['table']['base'] = array(
    'field' => 'content_id',
    'title' => t('Flaggings'),
    'help' => t('Get at the individual flaggings.'),
    'numeric' => TRUE,
  );

'field' should point to 'fcid', of course, not to 'content_id'. (That snippet was written long ago, when we didn't yet have a primary key on that table.)

#3

Rosamunda - February 9, 2009 - 20:07

subscribing!

#4

mooffie - March 23, 2009 - 21:22

Another reason to expose this table:

Is there any trick to making the view sort on total flags within the past 24 hours?

If we expose this table, we will be able to do a "summary" on the flaggings done during the past X days/hours/etc.

#5

mooffie - May 1, 2009 - 11:29

Another reason to expose this table:

I need to get all flagged nodes from the users I have flagged.

[...]

Flag's Views implementation [...] should make the flagged content table (node) available for use as fields, filters, arguments, etc.

The patch achieves this by exposing three relationships: "The flagged node", "The flagged comment", The flagged user".

#6

mooffie - May 1, 2009 - 11:35

Another reason to expose this table:

[I want to add a section] "Users who have favorited this object have also favorited..."

(The "flagged node" relationship I mentioned in the previous reply solves this as well.)

#7

mooffie - May 3, 2009 - 22:28

There are many reasons to exposes this table. The code here complements the "flagging flaggings" feature which in itself solves many feature requests.

#8

opensanta - May 17, 2009 - 04:49

Tagging as 'flag 1.2' to try to help draw more attention to it.

Also added #464970: Natively support aliases for base tables.

#9

opensanta - May 17, 2009 - 07:49
Component:Code» Views integration

Marked #433308: Get all nodes from all users I have flagged? (Flag Users) as a duplicate of this issue.

Moving.

#10

camaromelt - November 5, 2009 - 04:02

I feel this would be a great addition as I am wanting to also view the number of flags a node has in a given timeframe and then cause the top flagged item to be hard posted to a front page. Any thoughts if this idea is on the same wavelength? I'd love to get involved but I am totally newb with PHP.

#11

jday - November 5, 2009 - 20:09

I would like the table exposed in views so that we can create a view of all the users who have flagged a particular node.

#12

quicksketch - November 6, 2009 - 01:25

I would like the table exposed in views so that we can create a view of all the users who have flagged a particular node.

You can do that already. See the handbook page on this exact task: http://drupal.org/node/326308

#13

jday - November 11, 2009 - 06:21

ok almost have it, the handbook says
"you can easily turn it into a block. Add a "Block" display. Since blocks don't get arguments from the URL, you'll have to add the "Node ID from URL" default argument."

but I don't see this "Node ID from URL" option, where is it?

Nevermind, found it under "Provide default argument"

 
 

Drupal is a registered trademark of Dries Buytaert.