Posted by eliza411 on March 17, 2009 at 3:57pm
Jump to:
| Project: | Flag |
| Version: | 5.x-1.1 |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Is it possible have an AJAX flag link in the teaser of a node and a regular flag link in the full node?
I know that with views I can create a regular link, one that reloads the page, regardless of what settings I have on an individual flag.
I'm hoping I could make the same kind of choice in a template file.
Thanks in advance for any help you can provide.
Comments
#1
You can, but you can't use the flag_create_link() function. You'll need to manually set the link_type type and then do the theming yourself.
<?php$flag = flag_get_flag($flag_name);
if ($flag->user_access() && $flag->applies_to_content_id($content_id)) {
$flag->link_type = 'normal'; // Or 'toggle' for AJAX.
print $flag->theme($flag->is_flagged($node->nid) ? 'unflag' : 'flag', $node->nid);
}
?>
#2
Nate, that code probably isn't forward-compatible (we're planning to streamline the access interface, don't we?).
I've opened a feature request: #405580: Add $options parameter to flag_create_link()
#3
Yes, it's likely that the code above would eventually change (say in a 2.x version), I really like mooffie's suggestion of making flag_create_link() take an argument, seems like it could be extremely useful.
#4
Removed a module hack that let us get a bunch of work done. Code from reply #1 does the same thing without changing the module.
#5
Whoa whoa whoa! Hacking a module (even temporarily) is a much worse solution. I'd suggest using my code from #1 until we get #405580: Add $options parameter to flag_create_link() done. Or alternatively start working on a patch for #405580: Add $options parameter to flag_create_link() and then you don't need to worry about upgrading if your site uses a patch that will eventually be committed.
#6
Marking as fixed.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.