Updating flag count via ajax
Flying Drupalist - November 11, 2008 - 18:23
| Project: | Flag |
| Version: | 6.x-1.x-dev |
| Component: | Flag core |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hi, I know I can get the flag count display by doing this:
$flag->get_count($content_id)
But the number doesn't display by ajax, how can I do that? Thanks.

#1
I'm not sure what you mean by this. The only thing I can assume is that you are displaying a count in your flag link's text, in which case it would be more practical to use the token for the count in your flag's settings.
If I'm assuming wrong, can you please elaborate where you are trying to use
$flag->get_count()?#2
Hi, I'm trying to get the number of flag counts to display like digg. It's that page in the docs that I got $flag->get_count() from. So it's not in my flag text link, but close by. However I need the count to update via ajax so it looks like digg. Thanks.
#3
You would have to write your own custom jQuery to handle that.
I would suggest using the token in your flag's text and then styling it to put a background image. But that's without seeing your design.
#4
Thank you sirkitree, but how would I style the count token independently of the text token?
#5
I don't think you'd be able to style them separately as they'd be the same element. However, I think that the return text can take in a token as well and maybe that could be where you put your count, that would make it a separate element and give the ability to style it differently then the text.
#6
Miraploy, you don't need to know anything about Ajax.
1. As theme/README.txt explains:
1.a Copy flag.tpl.php into flag-YOURFLAGFNAME.tpl.php.
1.b Move it into your theme folder.
1.c Clear Drupal's cache.
2. Put $flag->get_count($content_id) in that file. Whatever in that tpl file is fetched anew with every mouse click.
#7
Ahh I was not aware of that, thanks mooffie.
#8
Automatically closed -- issue fixed for two weeks with no activity.
#9
Can also be done through tokens. see http://drupal.org/node/319491.