Posted by Grzegorz Zbiński on February 23, 2012 at 6:21pm
5 followers
Jump to:
Issue Summary
I'm trying to print flags related to row of my view using Views PHPprint flag_create_link('myflag', $row->nid);
No result. Any idea?
I'm trying to print flags related to row of my view using Views PHPprint flag_create_link('myflag', $row->nid);
No result. Any idea?
Comments
#1
try this method
$myflagl=flag_create_link('myflag', $row->nid);
print $myflag;
#2
I know, why it wasn't rendered.
I've put:
<?phpprint flag_create_link('myflag', $row->nid);
?>
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).#3
Automatically closed -- issue fixed for 2 weeks with no activity.
#4
How 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
<?php$requester_firstd = $data->_field_data['nid']['entity']->field_requester_user['und'][0]['value'];
print flag_create_link('date_showup', $requester_firstd);
?>
<?php$requester_firstd = $data->_field_data['nid']['entity']->field_requester_user['und'][0]['uid'];
print flag_create_link('date_showup', $requester_firstd);
?>
I got Notice: Undefined index: value in __lambda_func() and Notice: Undefined index: uid in __lambda_func()
#5
My solution:
<?php
global $user;
$requester_user = db_query("SELECT field_requester_user_target_id FROM {field_data_field_requester_user} WHERE entity_id IN ($row->nid)")->fetchField();
$requestee_user = db_query("SELECT field_requestee_user_target_id FROM {field_data_field_requestee_user} WHERE entity_id IN ($row->nid)")->fetchField();
$current_user = $user->uid;
if($current_user == $requester_user)
{print flag_create_link('date_showup', $requestee_user_1st);}
else if($current_user == $requestee_user)
{print flag_create_link('date_showup', $requester_user);}
?>