开发者

Unpredictable CCK field name in returned View data

开发者 https://www.devze.com 2023-01-02 13:02 出处:网络
I\'m using views_get_view_result to directly access the data in a view.I\'ve stumbled upon this odd behavior where cck fields are prefixed with the first field name as a query optimization.Expl开发者_

I'm using views_get_view_result to directly access the data in a view. I've stumbled upon this odd behavior where cck fields are prefixed with the first field name as a query optimization. Expl开发者_如何学运维ained here.

What's bizarre though is that fields are named differently depending on whether I retrieve that data as Anonymous or as Admin. I'm pretty sure all my permissions are set up, and the view itself has no restrictions. What is going on here?

This is a big problem since I can't know how to retrieve a field. Here's a dump of the two view results. Notice that node_data_field_game_date_field_game_home_score_value != node_data_field_game_official_field_game_home_score_value.

// View as Admin
stdClass Object
(
    [nid] => 3191
    [node_data_field_game_date_field_game_date_value] => 2010-03-27T00:00:00
    [node_type] => game
    [node_vid] => 5039
    [node_data_field_game_date_field_game_official_value] => 0
    [node_node_data_field_game_home_team_title] => TeamA
    [node_node_data_field_game_home_team_nid] => 3396
    [node_data_field_game_date_field_game_home_score_value] => 68
    [node_node_data_field_game_visitor_team_title] => TeamB
    [node_node_data_field_game_visitor_team_nid] => 3442
    [node_data_field_game_date_field_game_visitor_score_value] => 118
)


// View as Anonymous
stdClass Object
(
    [nid] => 3191
    [node_data_field_game_date_field_game_date_value] => 2010-03-27T00:00:00
    [node_type] => game
    [node_vid] => 5039
    [node_data_field_game_official_field_game_official_value] => 0
    [node_node_data_field_game_home_team_title] => TeamA
    [node_node_data_field_game_home_team_nid] => 3396
    [node_data_field_game_official_field_game_home_score_value] => 68
    [node_node_data_field_game_visitor_team_title] => TeamB
    [node_node_data_field_game_visitor_team_nid] => 3442
    [node_data_field_game_official_field_game_visitor_score_value] => 118
)


Very weird behavior. Maybe it's a problem with content permission?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号