By solidad on
I have the following code in my page.tpl.php:
<?php
$flag = flag_get_flag('flag1');
if ($flag && $flag->is_flagged($node->nid) && ($flag->name == 'flag1')) {
print "this is flagged with flag1";
}
$flag = flag_get_flag('flag2');
if ($flag && $flag->is_flagged($node->nid) && ($flag->name == 'flag2')) {
print "this is flagged with flag2";
}
?>
this works, but it seems terribly inefficient. What I would like to do is call up the array that was generated by the flag module itself once, instead of constantly calling individual flags. I am just not sure how to go about this. I tried looking at the module code, and template override code, but it just seems too much for what I want to do. I really just want to call each flag and then print text if the flag "is flagged" and it's names matches one of the flag names I created.
Comments
You could generate the $flags
You could generate the $flags array using a custom query to rather than hard-coding it in. I'm not too familiar with the flags module to know what table and field to query.
-= Gerrit Brands
hmm it gets a syntax error.
hmm it gets a syntax error. I don't know if it matters which tables are queried but it may. It does look exactly what I wanted to do though.
Sorry. I didn't have enough
Sorry. I didn't have enough parenthesis:
If($check.... line
-= Gerrit Brands
That works perfectly! I
That works perfectly! I didn't see the bracket either hence my confusion