I want to add flag counter of content in views field. Authenticated users can flag(bookmark) contents. I want to know how many users flaged a content, And I want to add this in views field(display the number of times a node is flagged by a certain flag by Users).
Notice; I'm using "Search API Index" in content part of views
How can I do it?
UPDATE Question after using Vicky8888 method;
I added below code in global php field of views
<?php
$flag = flag_get_flag('bookmarks');
if ($flag) {
print "Number of Flags:";
print $flag->get_count($node->nid);
}
?>
this code work in tpl.php file of content type, But It's showing "0" in views. I got several errors in picture too.
after that I using JS code of Vicky8888.
Drupal.behaviors.your-theme = {
attach: function (context, settings) {
//add your available class below
jQuery('.view-id-top_users.view-display-id-page .views-field-php .flag-link-toggle').click(function(){
jQuery(document).ajaxComplete(function() {
location.reload();
});
});
}
};
I cleared "your-theme" and added "adaptivetheme", and cleared classes and added ".view-content .views-field.views-field-php .field-content .flag-link-toggle".
after that I using this code in separate file and added
scripts[]=scripts/extracode.js
in adaptivetheme.info file.
I cleared cache and run cron too. but It didn't work too.