I’m trying to implement a “rating” system with Relation module. I have a Relation Type defined from a user –> node. The Relation Type has an Integer field to hold the rating.
I want to produce a view that shows the number of ratings and average rating. To start, I created a view with a list of nodes. I previously created a few “rating” relations between users and the nodes in the view, which can be seen in the Relations tab in content.
In views UI Advanced section, I added the Relationship from the node to its Relation. I added a view field for the Integer field on the Relation.
The label for the rating field shows, but the number is empty, even for relations I know are there.
Here is an export of the view:
$view = new view(); $view->name = 'offer_ratings'; $view->description = ''; $view->tag = 'default'; $view->base_table = 'node'; $view->human_name = 'Offer Ratings'; $view->core = 7; $view->api_version = '3.0'; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ /* Display: Master */ $handler = $view->new_display('default', 'Master', 'default'); $handler->display->display_options['title'] = 'Offer Ratings'; $handler->display->display_options['use_more_always'] = FALSE; $handler->display->display_options['access']['type'] = 'perm'; $handler->display->display_options['cache']['type'] = 'none'; $handler->display->display_options['query']['type'] = 'views_query'; $handler->display->display_options['exposed_form']['type'] = 'basic'; $handler->display->display_options['pager']['type'] = 'full'; $handler->display->display_options['pager']['options']['items_per_page'] = '100'; $handler->display->display_options['style_plugin'] = 'default'; $handler->display->display_options['row_plugin'] = 'fields'; /* Relationship: Content: Relation: rated by (node → relation) */ $handler->display->display_options['relationships']['relation_base_right_rated']['id'] = 'relation_base_right_rated'; $handler->display->display_options['relationships']['relation_base_right_rated']['table'] = 'node'; $handler->display->display_options['relationships']['relation_base_right_rated']['field'] = 'relation_base_right_rated'; $handler->display->display_options['relationships']['relation_base_right_rated']['r_index'] = '1'; $handler->display->display_options['relationships']['relation_base_right_rated']['entity_deduplication_right'] = 0; /* Field: Content: Title */ $handler->display->display_options['fields']['title']['id'] = 'title'; $handler->display->display_options['fields']['title']['table'] = 'node'; $handler->display->display_options['fields']['title']['field'] = 'title'; $handler->display->display_options['fields']['title']['label'] = ''; $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; /* Field: Relation: Rating */ $handler->display->display_options['fields']['field_rating']['id'] = 'field_rating'; $handler->display->display_options['fields']['field_rating']['table'] = 'field_data_field_rating'; $handler->display->display_options['fields']['field_rating']['field'] = 'field_rating'; $handler->display->display_options['fields']['field_rating']['relationship'] = 'relation_base_right_rated'; $handler->display->display_options['fields']['field_rating']['settings'] = array( 'thousand_separator' => '', 'prefix_suffix' => 1, ); /* Sort criterion: Content: Post date */ $handler->display->display_options['sorts']['created']['id'] = 'created'; $handler->display->display_options['sorts']['created']['table'] = 'node'; $handler->display->display_options['sorts']['created']['field'] = 'created'; $handler->display->display_options['sorts']['created']['order'] = 'DESC'; /* Filter criterion: Content: Published */ $handler->display->display_options['filters']['status']['id'] = 'status'; $handler->display->display_options['filters']['status']['table'] = 'node'; $handler->display->display_options['filters']['status']['field'] = 'status'; $handler->display->display_options['filters']['status']['value'] = 1; $handler->display->display_options['filters']['status']['group'] = 1; $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; /* Filter criterion: Content: Type */ $handler->display->display_options['filters']['type']['id'] = 'type'; $handler->display->display_options['filters']['type']['table'] = 'node'; $handler->display->display_options['filters']['type']['field'] = 'type'; $handler->display->display_options['filters']['type']['value'] = array( 'offer' => 'offer', ); /* Display: Page */ $handler = $view->new_display('page', 'Page', 'page'); $handler->display->display_options['path'] = 'offer-ratings';
Sponsored by SupremePR