function flag_create_link in Flag 6.2
Same name and namespace in other branches
- 5 flag.module \flag_create_link()
- 6 flag.module \flag_create_link()
- 7.3 flag.module \flag_create_link()
- 7.2 flag.module \flag_create_link()
A utility function for outputting a flag link.
You should call this function from your template when you want to put the link on the page yourself. For example, you could call this function from your 'node.tpl.php':
<?php print flag_create_link('bookmarks', $node->nid); ?>
Parameters
$flag_name: The "machine readable" name of the flag; e.g. 'bookmarks'.
$content_id: The content ID to check for flagging. This is usually a node ID.
1 call to flag_create_link()
- flag_token_values in includes/
flag.token.inc - Implementation of hook_token_values().
File
- ./
flag.module, line 1594 - The Flag module.
Code
function flag_create_link($flag_name, $content_id) {
$flag = flag_get_flag($flag_name);
if (!$flag) {
// Flag does not exist.
return;
}
if (!$flag
->access($content_id) && (!$flag
->is_flagged($content_id) || !$flag
->access($content_id, 'flag'))) {
// User has no permission to use this flag.
return;
}
return $flag
->theme($flag
->is_flagged($content_id) ? 'unflag' : 'flag', $content_id);
}