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.
According to the help docs, 'extra type' is a key on 'extra':
extra
Either a string that's directly added, or an array of items. Each item is, itself, an array:
field
Field or formula
operator
Similar to filters, this is the operator, such as >, <, =, etc. Defaults to = or IN.
value
Must be set. If an array, operator will be defaulted to IN.
numeric
If true, the value will not be surrounded in quotes, and %d will be used for its placeholder.
extra type
How all the extras will be combined. Either AND or OR. Defaults to AND.
However, the description is:
"How all the extras will be combined. Either AND or OR. Defaults to AND."
Which is a bit confusing -- if it's set on each extra, but it tells how to combine them all, surely there's redundancy?
Testing this, it looks like the description is correct, but the location of the key in the list is wrong.
If I put an extra type within the extra, they have no effect:
// Image table, aliased for base table node.
$data['image_node']['table']['group'] = t('Image');
// Explain how this table joins to others.
$data['image_node']['table']['join'] = array(
'node' => array(
// Directly links to node table.
'left_field' => 'nid',
'table' => 'image', // because image_node is an alias
'field' => 'nid',
'extra' => array(
'image_size' => array(
'field' => 'image_size',
'extra type' => 'OR',
// this will be set to the desired derivative size by the handler
'value' => '****IMAGE_DERIVATIVE****',
),
'image_size_fallback' => array(
'field' => 'image_size',
'extra type' => 'OR',
'value' => 'IMAGE_ORIGINAL',
),
),
),
);
// I get ANDs in my query
<code>
If I set the extra type on the join, it works as expected:
<code>
// Image table, aliased for base table node.
$data['image_node']['table']['group'] = t('Image');
// Explain how this table joins to others.
$data['image_node']['table']['join'] = array(
'node' => array(
// Directly links to node table.
'left_field' => 'nid',
'table' => 'image', // because image_node is an alias
'field' => 'nid',
'extra type' => 'OR',
'extra' => array(
'image_size' => array(
'field' => 'image_size',
'extra type' => 'OR',
// this will be set to the desired derivative size by the handler
'value' => '****IMAGE_DERIVATIVE****',
),
'image_size_fallback' => array(
'field' => 'image_size',
'value' => 'IMAGE_ORIGINAL',
),
),
),
);
// I get the OR as expected.
Comment | File | Size | Author |
---|---|---|---|
#2 | 403678-join-extra_type-doc.patch | 714 bytes | dawehner |
Comments
Comment #1
joachim CreditAttribution: joachim commentedFollowing chat on IRC... bug is in sites/all/modules/views/help/api-tables.html -- extra type is in the wrong DL.
Comment #2
dawehnerHere is a patch to fix this bug in the documentation
Comment #3
esmerel CreditAttribution: esmerel commentedLooks ok to me
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted to all branches.
Comment #5
benoit.borrel CreditAttribution: benoit.borrel commentedHi,
Could someone fix it here (http://views-help.doc.logrus.com/help/views/api-tables) as well?
Thank you
Comment #6
dawehnerAssign to merlinofchaos, afaik he has to cvs update.