Hello,

I'm doing a custom theme where the area to flag my content and the area to add comments are on separate parts of the page. On some nodes I don't even allow comments. I really don't want my flag links lumped into the $links array. Is there a way to create a $flag_links array (separate menu) or, how can I remove the Add Comments link from the links array? I'd prefer the first option. Thanks for your thoughts,

Blue

Comments

quicksketch’s picture

You can simply not enable the flag link when you configure the flag. Then you can use flag_create_link() to place the link wherever you want. See http://drupal.org/node/295383.

blue92877’s picture

Hey, that works great! Thanks for the reply.

I'm not very good with PHP, but would it be possible to extend the functionality above by having PHP count the number of custom flags I have created, add them to an array, and spit them back out as an HTML list?

count_number_of_custom_flags();
while(number_of_flags) {

print flag_create_link("flag_name[number_of_flags]);

}

Sorry for the quick pseudocode, but hopefully it's enough to illustrate my point. The above solution works great and so is the article, but I'd hope to create a situation where any additional flags were automatically added to the results.

Thanks!

quicksketch’s picture

Yes, you can do this simply by using flag_get_flags() and then looping through them and printing out the links. I don't provide support on custom coding in the issue queue though, so your exact code is something you'll have to figure out.

blue92877’s picture

That did exactly what I needed! Thanks!

Here is the code I created in case anyone else has the same issue. Based on the above suggestion of not enabling the flag link, this function will allow you to put your list of flags wherever you want on your page:

function get_flag_links($nid){
	$flags = flag_get_flags();
	
	foreach ($flags as $key => $value){
		print flag_create_link($flags[$key]->name, $nid);
	}
}

Use CSS to style and voila, you have your own custom flags menu!

quicksketch’s picture

Status: Active » Fixed

Super, sounds like we can mark this fixed.

Status: Fixed » Closed (fixed)

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