class content_profile_views_handler_relationship in Content Profile 6
Specialized relationship handler to adding content profiles.
Hierarchy
- class \content_profile_views_handler_relationship extends \views_handler_relationship
Expanded class hierarchy of content_profile_views_handler_relationship
1 string reference to 'content_profile_views_handler_relationship'
- content_profile_views_data_alter in views/
content_profile.views.inc - Implementation of hook_views_data_alter().
File
- views/
content_profile_views_handler_relationship.inc, line 7
View source
class content_profile_views_handler_relationship extends views_handler_relationship {
function option_definition() {
$options = parent::option_definition();
$options['type'] = array(
'default' => '',
);
return $options;
}
/**
* Adds a form element for choosing the right content type.
*/
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['type'] = array(
'#type' => 'radios',
'#title' => t('Content type'),
'#default_value' => $this->options['type'],
'#options' => content_profile_get_types('names'),
'#required' => TRUE,
);
}
/**
* Called to implement a relationship in a query.
*/
function query() {
// Figure out what base table this relationship brings to the party.
$join = new views_join();
$join->definition = array(
'table' => 'node',
'field' => 'uid',
'left_table' => !empty($this->relationship) ? $this->relationship : 'users',
'left_field' => 'uid',
'extra' => array(
array(
'field' => 'type',
'value' => $this->options['type'],
),
),
);
if (!empty($this->options['required'])) {
$join->definition['type'] = 'INNER';
}
$join
->construct();
$this
->ensure_my_table();
$alias = $join->definition['table'] . '_' . $join->definition['left_table'];
$this->alias = $this->query
->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
content_profile_views_handler_relationship:: |
function | Adds a form element for choosing the right content type. | ||
content_profile_views_handler_relationship:: |
function | |||
content_profile_views_handler_relationship:: |
function | Called to implement a relationship in a query. |