How to implement Digg-like links

Last updated on
30 April 2025

Having links that show the number of times some content is flagged is easy. All that's needed is to embed a count token in the labels for the links. (You have to have the Token module enabled for this, or for any other token, to work.)

On the flag configuration form, change, for example:

Bookmark this

To:

Bookmark this ([node:flag-bookmarks-count] users have bookmarked this)

You should change the "bookmarks" word, in the token, to the machine name of the flag you're dealing with. It's easier to just open the Tokens fieldset and locate the desired token in the list.

For this feature to work correctly, your Flag module release must be from 2008-10-10 or later.

Global vs non-global flags

Note that the count token is only useful with non-global flags. Global flags are shared among all users and their count tokens will always show either '1' (if the content is flagged) or '0' (if the content isn't flagged).

If you aren't satisfied with plain textual links, if you want to show the number in big type, inside a stylish box, then you can override flag.tpl.php. Some tips:

  • The expression $flag->get_count($content_id) would give you the number of times the content is flagged. (See the API section.)
  • You may wish to replace all the SPANs with DIVs.
  • You may wish to remove the link from the links section beneath the node and instead place it floating beside the node title; See Placing a flag link on a page

Help improve this page

Page status: Not set

You can: