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
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

sirkitree - November 11, 2008 - 23:16
Status:active» postponed (maintainer needs more info)

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

Flying Drupalist - November 12, 2008 - 01:12

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

sirkitree - November 12, 2008 - 01:18

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

Flying Drupalist - November 12, 2008 - 02:03

Thank you sirkitree, but how would I style the count token independently of the text token?

#5

sirkitree - November 12, 2008 - 02:51

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

mooffie - November 12, 2008 - 10:48
Status:postponed (maintainer needs more info)» fixed

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

Flying Drupalist - November 12, 2008 - 20:40

Ahh I was not aware of that, thanks mooffie.

#8

System Message - November 26, 2008 - 20:44
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#9

nedjo - November 11, 2009 - 21:15
Component:Code» Flag core

Can also be done through tokens. see http://drupal.org/node/319491.

 
 

Drupal is a registered trademark of Dries Buytaert.