Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm trying to print flags related to row of my view using Views PHP
print flag_create_link('myflag', $row->nid);
No result. Any idea?
Comments
Comment #1
smouhaer CreditAttribution: smouhaer commentedtry this method
$myflagl=flag_create_link('myflag', $row->nid);
print $myflag;
Comment #2
Grzegorz Zbiński CreditAttribution: Grzegorz Zbiński commentedI know, why it wasn't rendered.
I've put:
into wrong place...
It should be in Output code (and I've put it in Value code, which was wrong). Now it is working fantastic!
I've checked dblog where goes things like those:
Notice: Undefined variable: flag in __lambda_func() (line 1 from .../sites/all/modules/views_php/plugins/views/views_php_handler_field.inc(131) : runtime-created function).
and
Notice: Undefined property: stdClass::$views_php_15 in views_php_handler_field->render() (line 223 from .../sites/all/modules/views_php/plugins/views/views_php_handler_field.inc).
Comment #4
fehin CreditAttribution: fehin commentedHow do I print a flag link for users and use a user reference field instead.
I have tried different method. The last one I tried was
and
but it didn't work.
I got Notice: Undefined index: value in __lambda_func() and Notice: Undefined index: uid in __lambda_func()
Comment #5
fehin CreditAttribution: fehin commentedMy solution:
Comment #6
bharata CreditAttribution: bharata commentedI'm trying to follow in your footsteps Grzegorz, and would like to ask you two questions.
Am I correct that I must leave out the begining and ending PHP tags?
Also, does it make a differece if I use " or ' ? 'myflag' vs "myflag"?
Just wanting ot be sure I am doing it correctly. It's not working anyway but I could rule syntax out if I'm at least entering the code in correctly.
I am still seeing:
Notice: Undefined property: stdClass::$views_php_2 in views_php_handler_field->render() (line 223 from .../sites/all/modules/views_php/plugins/views/views_php_handler_field.inc).
Thanks!
Comment #7
bharata CreditAttribution: bharata commentedOK. I solved my problem. Grzegorz bold faced the answer. Others on other threads have mentioned this as well. But regardless, I did not actually understand because at the top of the entry screen for the global PHP field it says,
I assumed that meant I was doing the right thing. Wrong! You must scroll down. There are TWO fields.
Enter your code into the SECOND one. And DO use PHP tags.
Comment #8
marcoka CreditAttribution: marcoka commenteddeleted my comment. wrong statement.