summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--includes/views/handlers/content_handler_field_multiple.inc36
2 files changed, 27 insertions, 10 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 2caf9f5..b45a1b8 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -40,6 +40,7 @@ CCK 6.2-dev
- #327715 Babysit 'invalid foreach' warnings caused by invalid incoming $node objects.
- #328763 Adjust weight of non-cck fields even if there are no CCK fields for the content type.
- Views integration: fixed a few non-relationship safe areas.
+- Views integration: fix 'link this field to its node'+'group multiple'+relationships.
CCK 6.2-rc10
============
diff --git a/includes/views/handlers/content_handler_field_multiple.inc b/includes/views/handlers/content_handler_field_multiple.inc
index 0ecbe57..692137d 100644
--- a/includes/views/handlers/content_handler_field_multiple.inc
+++ b/includes/views/handlers/content_handler_field_multiple.inc
@@ -136,11 +136,14 @@ class content_handler_field_multiple extends content_handler_field {
// List columns to retrieve.
$alias = content_views_tablename($field);
+ // Prefix aliases with '_' to avoid clashing with field columns names.
$query_columns = array(
- // Prefix with '_' to avoid clashing with field columns named 'vid' or 'delta'.
- "node.vid AS _vid",
- "$alias.delta as _delta"
+ 'node.vid AS _vid',
+ "$alias.delta as _delta",
+ // nid is needed to generate the links for 'link to node' option.
+ 'node.nid AS _nid',
);
+ // The actual field columns.
foreach ($db_info['columns'] as $column => $attributes) {
$query_columns[] = "$alias.$attributes[column] AS $column";
}
@@ -152,6 +155,7 @@ class content_handler_field_multiple extends content_handler_field {
$result = db_query($query);
while ($item = db_fetch_array($result)) {
+ // Clean up the $item from vid and delta. We keep nid for now.
$vid = $item['_vid'];
unset($item['_vid']);
$delta = !empty($item['_delta']) ? $item['_delta'] : 0;
@@ -170,11 +174,6 @@ class content_handler_field_multiple extends content_handler_field {
$field = $this->content_field;
$options = $this->options;
- // This needs to be set for the $this->render_link() to work. It would
- // have been set in the query, if we hadn't bypassed the normal query.
- // TODO : Not relatioship safe !.
- $this->aliases['nid'] = 'nid';
-
$vid = $values->{$this->field_alias};
if (isset($this->field_values[$vid])) {
// Gather items, respecting the 'Display n values starting from m' settings.
@@ -183,6 +182,9 @@ class content_handler_field_multiple extends content_handler_field {
foreach ($this->field_values[$vid] as $item) {
if (empty($options['multiple']['multiple_from']) || ($count_skipped >= $options['multiple']['multiple_from'])) {
if (empty($options['multiple']['multiple_number']) || (count($items) < $options['multiple']['multiple_number'])) {
+ // Grab the nid - needed for render_link().
+ $nid = $item['_nid'];
+ unset($item['_nid']);
$items[] = $item;
}
else {
@@ -209,7 +211,7 @@ class content_handler_field_multiple extends content_handler_field {
foreach ($items as $item) {
$output = content_format($field, $item, $formatter_name, $node);
if (!empty($output)) {
- $rendered[] = $this->render_link($output, $values);
+ $rendered[] = $this->render_link($output, (object) array('nid' => $nid));
}
}
}
@@ -217,7 +219,7 @@ class content_handler_field_multiple extends content_handler_field {
// Multiple values formatter.
$output = content_format($field, $items, $formatter_name, $values);
if (!empty($output)) {
- $rendered[] = $this->render_link($output, $values);
+ $rendered[] = $this->render_link($output, (object) array('nid' => $nid));
}
}
@@ -233,4 +235,18 @@ class content_handler_field_multiple extends content_handler_field {
return '';
}
+
+ function render_link($data, $values) {
+ if (!$this->defer_query || empty($this->field_values)) {
+ return parent::render_link($data, $values);
+ }
+
+ if (!empty($this->options['link_to_node'])) {
+ return l($data, "node/" . $values->nid, array('html' => TRUE));
+ }
+ else {
+ return $data;
+ }
+ }
+
} \ No newline at end of file