Hi,
Can we get count of flags for flag list? that means for a single flag list how many are flagged in that along with the ajax ?

Thanks & regads,
Nagarjuna.

Comments

joelrosen’s picture

I also needed to do this and I believe you can get it without hacking Flag List by adding this to your own custom module:

function HOOK_views_data_alter(&$data) {
  $data['flag_lists_content']['table']['join']['flag_lists_flags'] = array(
    'left_field' => 'fid',
    'field' => 'fid'
  );
}

This should add a "Relationship" in your Flag List view so you can access flagged nodes, and then use aggregation to get a count of the nodes in each flag list. It seems to be working for me. Maybe this should be patched in?

queenvictoria’s picture

Status: Active » Needs review
StatusFileSize
new1.2 KB

Here is a patch to add the [flag_list:count] token which you can use in your template link text at http://example.com/admin/structure/flags/manage/fl_template

This gets used in the AJAX callback too so it will go all the way through the system (which is what the OP was after).

Note: only new lists will get the corrected message. It looks like the master message is stored in the flag table where as the one that actually gets used is in the flag_list_flags table which is not updated when the template is re-saved. I'm looking for an issue queue on this.

queenvictoria’s picture

Here is an extended patch that adds utility methods for retrieving number of entities flagged, and number of times an entity has been flagged by a user. It also includes Views support for a Flag lists: count field, and reworks token support to use the new methods.

queenvictoria’s picture

Issue summary: View changes

change

sl27257’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)